[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: On the behaviour of the checkwinsize shopt from within a subshell
From: |
Koichi Murase |
Subject: |
Re: On the behaviour of the checkwinsize shopt from within a subshell |
Date: |
Tue, 21 Feb 2023 20:28:05 +0900 |
2023年2月21日(火) 18:19 Kerin Millar <kfm@plushkava.net>:
> In this case, the values of the variables were not updated from within the
> subshell, only the initial shell. I consider this to be surprising because
> the manual does not mention any such limitation. Consequently, the utility of
> the checkwinsize feature suffers in terms of being a potential alternative to
> the invocation of stty(1) with the "size" operand (an operand which will
> eventually be standard, but isn't yet).
I recently noticed that `checkwinsize' stopped working in the trap
string and the `bind -x' context from Bash 5.2, which broke my script.
Here's an example:
$ bash-5.1 --norc -O checkwinsize
$ trap 'echo $COLUMNS:$LINES; sleep 3; /bin/true; echo $COLUMNS:$LINES' WINCH
$ 215:45 /* <-- change the terminal size twice. Note: the latter
WINCH received while processing the first WINCH is discarded. */
239:75 /* <-- after /bin/true, it is updated. */
exit
$ bash-5.2 --norc -O checkwinsize
$ trap 'echo $COLUMNS:$LINES; sleep 3; /bin/true; echo $COLUMNS:$LINES' WINCH
$ 215:45 /* <-- change the terminal size twice. */
215:45 /* <-- now it's not updated after /bin/true. */
exit
It seems the behavior in the subshells didn't change in Bash 5.2
(i.e., checkwinsize didn't work in the subshells in 5.1 either), but I
also hope that `checkwinsize' would be changed to work in any context
(including subshells, trap handlers, bind -x, etc.).
--
Koichi