Changeset

13047:d939bf469057

util.human.io: Prefer using the $COLUMNS environment variable if set (by readline) Feels like it should be faster.
author Kim Alvefur <zash@zash.se>
date Fri, 07 Apr 2023 13:42:20 +0200
parents 13046:4c3dc767fb11
children 13048:946442df65d3
files util/human/io.lua util/prosodyctl/shell.lua
diffstat 2 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/util/human/io.lua	Fri Apr 07 13:38:59 2023 +0200
+++ b/util/human/io.lua	Fri Apr 07 13:42:20 2023 +0200
@@ -109,6 +109,8 @@
 end
 
 local function term_width(default)
+	local env_cols = os.getenv "COLUMNS";
+	if env_cols then return env_cols; end
 	local stty = io.popen("stty -a");
 	if not stty then return default; end
 	local result = stty:read("*a");
--- a/util/prosodyctl/shell.lua	Fri Apr 07 13:38:59 2023 +0200
+++ b/util/prosodyctl/shell.lua	Fri Apr 07 13:42:20 2023 +0200
@@ -30,7 +30,7 @@
 end
 
 local function send_line(client, line)
-	client.send(st.stanza("repl-input", { width = os.getenv "COLUMNS" or term_width() }):text(line));
+	client.send(st.stanza("repl-input", { width = term_width() }):text(line));
 end
 
 local function repl(client)