aboutsummaryrefslogtreecommitdiffstats
path: root/util/human/io.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2023-04-07 13:42:20 +0200
committerKim Alvefur <zash@zash.se>2023-04-07 13:42:20 +0200
commit9760019a25dbbb6e04d4ee1ee1366ea14fc0472e (patch)
treeb2a951151b92156055430bd602e7d1f00922d3d7 /util/human/io.lua
parentd73eaf9e5e6c49fff6262ce326bf193108f45695 (diff)
downloadprosody-9760019a25dbbb6e04d4ee1ee1366ea14fc0472e.tar.gz
prosody-9760019a25dbbb6e04d4ee1ee1366ea14fc0472e.zip
util.human.io: Prefer using the $COLUMNS environment variable if set (by readline)
Feels like it should be faster.
Diffstat (limited to 'util/human/io.lua')
-rw-r--r--util/human/io.lua2
1 files changed, 2 insertions, 0 deletions
diff --git a/util/human/io.lua b/util/human/io.lua
index 51a95ed5..e4bea63f 100644
--- a/util/human/io.lua
+++ b/util/human/io.lua
@@ -109,6 +109,8 @@ if utf8.len and utf8.offset then
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");