bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Gettings LINES and COLUMNS from stderr instead of /dev/tty


From: Martin Schulte
Subject: Gettings LINES and COLUMNS from stderr instead of /dev/tty
Date: Sat, 16 Jul 2022 17:18:59 +0200

Hello,

I'm just wondering that bash (reproduced with 5.2-rc1 under Debian 11) seems to 
determine LINES and COLUMNS from stderr.

For example, this will lead to strange results when starting the script

#!/bin/bash

shopt -s checkwinsize
trap 'echo $LINES $COLUMNS' SIGWINCH
while true; do sleep 0.1; done

with standard error redirected to a file (or - even more strange ;-) - another 
terminal).

A quick POC shows that replacing
  tty = input_tty ();
with
  tty = open( "/dev/tty", O_RDONLY );
in get_new_windows_size in lib/sh/winsize.c gives the "expected" result.

In case there is some reason not to use /dev/tty, wouldn't it then be better to 
ask stdin instead of stderr? The script will most probably be interested in the 
size of device it is writing to, not the one it is logging to.

Best regards

Martin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]