# HG changeset patch # User Kim Alvefur # Date 1680867740 -7200 # Node ID d939bf469057b5116ae514b9abc38d135e9e5590 # Parent 4c3dc767fb1144f85dd7335240b788dfb0a8f9b5 util.human.io: Prefer using the $COLUMNS environment variable if set (by readline) Feels like it should be faster. diff -r 4c3dc767fb11 -r d939bf469057 util/human/io.lua --- 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"); diff -r 4c3dc767fb11 -r d939bf469057 util/prosodyctl/shell.lua --- 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)