cksum: ensure appropriate "binary" mode with --untagged
[coreutils.git] / tests / stty / stty-row-col.sh
blobdd7366c6ef91c0c21734b68cfe5e78d9c85ac54d
1 #!/bin/sh
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.
21 COLUMNS=80
22 export COLUMNS
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.
28 LC_ALL=C
29 export LC_ALL
31 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
32 print_ver_ stty
34 require_controlling_input_terminal_
35 require_trap_signame_
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.
42 tests='
43 1 rows_40_columns_80 40_80
44 2 rows_1_columns_1 1_1
45 3 rows_40_columns_80 40_80
46 4 rows_1 1_80
47 5 columns_1 1_1
48 6 rows_40 40_1
49 7 rows_1 1_1
50 8 columns_80 1_80
51 9 rows_30 30_80
52 10 rows_0x1E 30_80
53 11 rows_036 30_80
54 NA LAST NA
56 set $tests
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"
70 while :; do
71 test_name=$1
72 args=$2
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'
81 stty $args || exit 1
82 test x"$(stty size 2> /dev/null)" = "x$expected_result" \
83 && ok=ok || ok=FAIL fail=1
84 test "$VERBOSE" = yes && echo $ok
85 shift; shift; shift
86 done
88 set x $saved_size
89 stty rows $2 columns $3 || exit 1
91 Exit $fail