f4b37dfdadd4edbe0e155ca4d37629f7a2f7b194
[platform/upstream/coreutils.git] / tests / stty / row-col-1
1 #! /bin/sh
2 # This script takes no arguments.
3
4 if test "$VERBOSE" = yes; then
5   set -x
6   stty --version
7 fi
8
9 # Setting this envvar to a very small value used to cause e.g., `stty size'
10 # to generate slightly different output on certain systems.
11 COLUMNS=80
12 export COLUMNS
13
14 # Make sure we get English-language behavior.
15 # See the report about a possibly-related Solaris problem by Alexandre Peshansky
16 # <http://lists.gnu.org/archive/html/bug-coreutils/2004-10/msg00035.html>.
17 # Currently stty isn't localized, but it might be in the future.
18 LC_ALL=C
19 export LC_ALL
20
21 # Make sure there's a tty on stdin.
22 . $srcdir/../input-tty
23
24 # Versions of GNU stty from shellutils-1.9.2c and earlier failed
25 # tests #2 and #4 when run on SunOS 4.1.3.
26
27 tests='
28 1 rows_40_columns_80 40_80
29 2 rows_1_columns_1 1_1
30 3 rows_40_columns_80 40_80
31 4 rows_1 1_80
32 5 columns_1 1_1
33 6 rows_40 40_1
34 7 rows_1 1_1
35 8 columns_80 1_80
36 9 rows_30 30_80
37 NA LAST NA
38 '
39 set $tests
40
41 saved_size=.saved-size
42
43 stty size > $saved_size \
44   || { echo "$0: skipping this test: can't get window size" 1>&2;
45        exit 77; exit; }
46
47 fail=0
48 while :; do
49   test_name=$1
50   args=$2
51   expected_result="`echo $3|tr _ ' '`"
52   test "$args" = empty && args=''
53   test "x$args" = xLAST && break
54   args=`echo x$args|tr _ ' '|sed 's/^x//'`
55   if test "$VERBOSE" = yes; then
56     # echo "testing \`stty $args; stty size\` = $expected_result ..."
57     echo "test $test_name... " | tr -d '\n'
58   fi
59   stty $args || exit 1
60   test x"`stty size 2> /dev/null`" = "x$expected_result" \
61     && ok=ok || ok=FAIL fail=1
62   test "$VERBOSE" = yes && echo $ok
63   shift; shift; shift
64 done
65
66 stty `cat $saved_size|sed 's/ / columns /;s/^/rows /'` || exit 1
67 rm -f $saved_size
68
69 exit $fail