[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
On the behaviour of the checkwinsize shopt from within a subshell
From: |
Kerin Millar |
Subject: |
On the behaviour of the checkwinsize shopt from within a subshell |
Date: |
Tue, 21 Feb 2023 09:18:32 +0000 |
I am writing to report that the documented behaviour of the checkwinsize shopt
can be impeded by the use of the subshell.
Firstly, some preliminaries.
$ declare -p BASH_VERSION
declare -- BASH_VERSION="5.2.15(1)-release"
$ shopt checkwinsize
checkwinsize on
$ sz() { /bin/true; declare -p COLUMNS LINES; }
In both of the following two cases, I manually resized the terminal window
during the time that bash was waiting for sleep to exit.
$ sz; sleep 3; sz
declare -- COLUMNS="86"
declare -- LINES="29"
declare -- COLUMNS="95"
declare -- LINES="34"
In this case, the values of the variables were updated as expected.
$ ( sz; sleep 3; sz )
declare -- COLUMNS="95"
declare -- LINES="34"
declare -- COLUMNS="95"
declare -- LINES="34"
$ declare -p COLUMNS LINES
declare -- COLUMNS="85"
declare -- LINES="31"
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).
--
Kerin Millar