On Thu, Aug 05, 2021 at 02:48:25PM -0500, Felipe Contreras wrote: > Since c49a177bec (test-lib.sh: set COLUMNS=80 for --verbose > repeatability, 2021-06-29) multiple tests have been failing when using > bash 5 because checkwinsize is enabled by default, therefore COLUMNS is > reset using TIOCGWINSZ even for non-interactive shells. > > It's debatable whether or not bash should even be doing that, but for > now we can avoid this undesirable behavior by disabling this option. > > Reported-by: Fabian Stelzer <fabian.stelzer@xxxxxxxxxxxx> > Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx> > --- > t/test-lib.sh | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/t/test-lib.sh b/t/test-lib.sh > index db61081d6b..a2b7dfecee 100644 > --- a/t/test-lib.sh > +++ b/t/test-lib.sh > @@ -419,6 +419,12 @@ COLUMNS=80 COLUMNS is set just before the start of the hunk context ... > export LANG LC_ALL PAGER TZ COLUMNS > EDITOR=: ... so these two "commands" above are executed while COLUMNS is already set but checkwinsize is not yet disabled. The reason I put quotes around that commands is that while exporting and setting variables are indeed commands as defined in the POSIX Shell Command Language specs, Bash with checkwinsize enabled only "checks the window size after each extern (non-builtin) command" (quoting 'man bash'). So even though it is safe to execute these variable setting and exporting commands after setting COLUMNS but disabling checkwinsize, I think it would be prudent to disable checkwinsize before initializing COLUMNS. (And perhaps adding "non-builtin" to the comment below.) > +# Since bash 5.0, checkwinsize is enabled by default which does update the > +# COLUMNS variable every time a command completes, even for non-interactive > +# shells. > +# Disable that since we are aiming for reproducibility. > +test -n "$BASH_VERSION" && shopt -u checkwinsize 2>/dev/null > + > # A call to "unset" with no arguments causes at least Solaris 10 > # /usr/xpg4/bin/sh and /bin/ksh to bail out. So keep the unsets > # deriving from the command substitution clustered with the other > -- > 2.32.0.40.gb9b36f9b52 >