Try stderr if we're asking for terminal size if stdout is not connected to a tty.

This commit is contained in:
Dianne Skoll
2025-12-29 17:30:56 -05:00
parent 59c434ce34
commit 6d4c38126e
2 changed files with 12 additions and 7 deletions

View File

@@ -4889,10 +4889,13 @@ rows_or_cols(func_info *info, int want_rows)
{
struct winsize w;
int fd = STDOUT_FILENO;
int opened = 0;
RetVal.type = INT_TYPE;
if (!isatty(fd)) {
/* Try STDERR fd if STDOUT fd is not a tty */
fd = STDERR_FILENO;
}
if (!isatty(fd)) {
fd = open("/dev/tty", O_RDONLY);
if (fd < 0) {