summaryrefslogtreecommitdiff
path: root/tests/stty/row-col-1
blob: edf2db501e51a6c49e81298b2c7f7bd96ab265cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#! /bin/sh
# This script takes no arguments.

if test "$VERBOSE" = yes; then
  set -x
  stty --version
fi

# Setting this envvar to a very small value used to cause e.g., `stty size'
# to generate slightly different output on certain systems.
COLUMNS=80
export COLUMNS

# Make sure we get English-language behavior.
# See the report about a possibly-related Solaris problem by Alexandre Peshansky
# <http://lists.gnu.org/archive/html/bug-coreutils/2004-10/msg00035.html>.
# Currently stty isn't localized, but it might be in the future.
LC_ALL=C
export LC_ALL

# Make sure there's a tty on stdin.
. $srcdir/../input-tty

# Versions of GNU stty from shellutils-1.9.2c and earlier failed
# tests #2 and #4 when run on SunOS 4.1.3.

tests='
1 rows_40_columns_80 40_80
2 rows_0_columns_0 0_0
3 rows_40_columns_80 40_80
4 rows_0 0_80
5 columns_0 0_0
6 rows_40 40_0
7 rows_0 0_0
8 columns_80 0_80
9 rows_30 30_80
NA LAST NA
'
set - $tests

saved_size=.saved-size

stty size > $saved_size \
  || { echo "$0: skipping this test: can't get window size" 1>&2;
       exit 77; exit; }

fail=0
while :; do
  test_name=$1
  args=$2
  expected_result="`echo $3|tr _ ' '`"
  test "$args" = empty && args=''
  test "x$args" = xLAST && break
  args=`echo x$args|tr _ ' '|sed 's/^x//'`
  if test "$VERBOSE" = yes; then
    # echo "testing \`stty $args; stty size\` = $expected_result ..."
    echo "test $test_name... " | tr -d '\n'
  fi
  stty $args || exit 1
  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

stty `cat $saved_size|sed 's/ / columns /;s/^/rows /'` || exit 1
rm -f $saved_size

exit $fail