2 # Test "stty" with rows and columns.
4 # Copyright (C) 1998-2024 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <https://www.gnu.org/licenses/>.
19 # Setting this envvar to a very small value used to cause e.g., 'stty size'
20 # to generate slightly different output on certain systems.
24 # Make sure we get English-language behavior.
25 # See the report about a possibly-related Solaris problem by Alexandre Peshansky
26 # <https://lists.gnu.org/r/bug-coreutils/2004-10/msg00035.html>.
27 # Currently stty isn't localized, but it might be in the future.
31 .
"${srcdir=.}/tests/init.sh"; path_prepend_ .
/src
34 require_controlling_input_terminal_
37 trap '' TTOU
# Ignore SIGTTOU
39 # Versions of GNU stty from shellutils-1.9.2c and earlier failed
40 # tests #2 and #4 when run on SunOS 4.1.3.
43 1 rows_40_columns_80 40_80
44 2 rows_1_columns_1 1_1
45 3 rows_40_columns_80 40_80
58 saved_size
=$
(stty size
) && test -n "$saved_size" \
59 || skip_
"can't get window size"
61 # Linux virtual consoles issue an error if you
62 # try to increase their size. So skip in that case.
63 if test "x$saved_size" != "x0 0"; then
64 srow
=$
(echo $saved_size | cut
-d ' ' -f1)
65 scol
=$
(echo $saved_size | cut
-d ' ' -f2)
66 stty rows $
(expr $srow + 1) cols $
(expr $scol + 1) ||
67 skip_
"can't increase window size"
73 expected_result
="$(echo $3|tr _ ' ')"
74 test "$args" = empty
&& args
=''
75 test "x$args" = xLAST
&& break
76 args
=$
(echo x
$args|
tr _
' '|
sed 's/^x//')
77 if test "$VERBOSE" = yes; then
78 # echo "testing \$(stty $args; stty size\) = $expected_result ..."
79 echo "test $test_name... " |
tr -d '\n'
82 test x
"$(stty size 2> /dev/null)" = "x$expected_result" \
83 && ok
=ok || ok
=FAIL fail
=1
84 test "$VERBOSE" = yes && echo $ok
89 stty rows
$2 columns
$3 ||
exit 1