2
# Test "stty" with rows and columns.
4
# Copyright (C) 1998-2001, 2003-2011 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 <http://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
# <http://lists.gnu.org/archive/html/bug-coreutils/2004-10/msg00035.html>.
27
# Currently stty isn't localized, but it might be in the future.
31
. "${srcdir=.}/init.sh"; path_prepend_ ../src
34
require_controlling_input_terminal_
35
trap '' TTOU # Ignore SIGTTOU
37
# Versions of GNU stty from shellutils-1.9.2c and earlier failed
38
# tests #2 and #4 when run on SunOS 4.1.3.
41
1 rows_40_columns_80 40_80
42
2 rows_1_columns_1 1_1
43
3 rows_40_columns_80 40_80
54
saved_size=`stty size` && test -n "$saved_size" \
55
|| skip_ "can't get window size"
57
# Linux virtual consoles issue an error if you
58
# try to increase their size. So skip in that case.
59
if test "x$saved_size" != "x0 0"; then
60
srow=$(echo $saved_size | cut -d ' ' -f1)
61
scol=$(echo $saved_size | cut -d ' ' -f2)
62
stty rows $(expr $srow + 1) cols $(expr $scol + 1) ||
63
skip_ "can't increase window size"
69
expected_result="`echo $3|tr _ ' '`"
70
test "$args" = empty && args=''
71
test "x$args" = xLAST && break
72
args=`echo x$args|tr _ ' '|sed 's/^x//'`
73
if test "$VERBOSE" = yes; then
74
# echo "testing \`stty $args; stty size\` = $expected_result ..."
75
echo "test $test_name... " | tr -d '\n'
78
test x"`stty size 2> /dev/null`" = "x$expected_result" \
79
&& ok=ok || ok=FAIL fail=1
80
test "$VERBOSE" = yes && echo $ok
85
stty rows $2 columns $3 || exit 1