2
# Make sure stty can parse most of its options.
4
# Copyright (C) 1998-2012 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
# Make sure there's a tty on stdin.
20
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
23
require_controlling_input_terminal_
24
trap '' TTOU # Ignore SIGTTOU
26
# Get the reversible settings from stty.c.
29
saved_state=.saved-state
30
stty --save > $saved_state || fail=1
31
stty $(cat $saved_state) || fail=1
33
# This would segfault prior to sh-utils-2.0j.
34
stty erase - || fail=1
36
# These would improperly ignore invalid options through coreutils 5.2.1.
37
stty -F 2>/dev/null && fail=1
38
stty -raw -F no/such/file 2>/dev/null && fail=1
39
stty -raw -a 2>/dev/null && fail=1
41
# Build a list of all boolean options stty accepts on this system.
42
# Don't depend on terminal width. Put each option on its own line,
43
# remove all non-boolean ones, then remove any leading hyphens.
44
sed_del='/^speed/d;/^rows/d;/^columns/d;/ = /d'
45
options=$(stty -a | tr -s ';' '\n' | sed "s/^ //;$sed_del;s/-//g")
47
# Take them one at a time, with and without the leading '-'.
48
for opt in $options; do
49
# 'stty parenb' and 'stty -parenb' fail with this message
50
# stty: standard input: unable to perform all requested operations
51
# on Linux 2.2.0-pre4 kernels. Also since around Linux 2.6.30
52
# other serial control settings give the same error. So skip them.
53
# Also on ppc*|sparc* glibc platforms 'icanon' gives the same error.
54
# See: http://debbugs.gnu.org/7228#14
55
case $opt in parenb|parodd|cstopb|crtscts|icanon) continue;; esac
59
# Likewise, 'stty -cread' would fail, so skip that, too.
60
test $opt = cread && continue
61
if stty_reversible_query_ "$opt" ; then
62
stty -$opt || { fail=1; echo -$opt; }
66
stty $(cat $saved_state)