Software /
code /
prosody
Changeset
13210:8dbe693ded6b
util.human.io: Fix stray 'stty' error by only querying width of real ttys
This adds a dependency on a binary and *nix-specific module but then
stty is probably *nix-specific anyway so maybe that's fine.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 16 Jul 2023 21:21:37 +0200 |
parents | 13209:c8d949cf6b09 |
children | 13211:4d4f9e42bcf8 |
files | util/human/io.lua |
diffstat | 1 files changed, 4 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/util/human/io.lua Sun Jul 16 20:49:33 2023 +0200 +++ b/util/human/io.lua Sun Jul 16 21:21:37 2023 +0200 @@ -1,4 +1,5 @@ local array = require "prosody.util.array"; +local pposix = require "prosody.util.pposix"; local utf8 = rawget(_G, "utf8") or require"prosody.util.encodings".utf8; local len = utf8.len or function(s) local _, count = s:gsub("[%z\001-\127\194-\253][\128-\191]*", ""); @@ -111,6 +112,9 @@ local function term_width(default) local env_cols = tonumber(os.getenv "COLUMNS"); if env_cols then return env_cols; end + if not pposix.isatty(io.stdout) then + return default; + end local stty = io.popen("stty -a"); if not stty then return default; end local result = stty:read("*a");