]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: stty: avoid false failure if resizing terminal
authorPádraig Brady <P@draigBrady.com>
Fri, 23 Jan 2026 18:24:53 +0000 (18:24 +0000)
committerPádraig Brady <P@draigBrady.com>
Sat, 24 Jan 2026 12:49:52 +0000 (12:49 +0000)
* tests/stty/stty-row-col.sh: Skip the test if we detect terminal
resizing.  Also more robustly restore the original size.

tests/stty/stty-row-col.sh

index d751db8ff444742fd0f9c16c8a972474599ed8f0..4229c28bb37916de0a38ef9577565feccab08a6e 100755 (executable)
@@ -58,6 +58,15 @@ set -- $tests
 saved_size=$(stty size) && test -n "$saved_size" \
   || skip_ "can't get window size"
 
+cleanup_()
+{
+  trap - WINCH
+  if test -n "$saved_size" && test "x$saved_size" != "x0 0"; then
+    set x $saved_size
+    stty rows $2 columns $3
+  fi
+}
+
 # Linux virtual consoles issue an error if you
 # try to increase their size.  So skip in that case.
 if test "x$saved_size" != "x0 0"; then
@@ -78,14 +87,14 @@ while :; do
     # echo "testing \$(stty $args; stty size\) = $expected_result ..."
     echo "test $test_name... " | tr -d '\n'
   fi
+  trap '' WINCH # Ignore terminal resizes
   stty $args || exit 1
+  # Skip if other terminal resizes detected
+  trap 'skip_ "terminal resize detected"' WINCH
   test x"$(stty size 2> /dev/null)" = "x$expected_result" \
     && ok=ok || ok=FAIL fail=1
   test "$VERBOSE" = yes && echo $ok
   shift; shift; shift
 done
 
-set x $saved_size
-stty rows $2 columns $3 || exit 1
-
 Exit $fail