2 # Make sure stty can parse most of its options - in pairs [expensive].
4 # Copyright (C) 1998-2013 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 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
24 # Make sure there's a tty on stdin.
25 require_controlling_input_terminal_
26 trap '' TTOU # Ignore SIGTTOU
28 # Get the reversible settings from stty.c.
31 saved_state=.saved-state
32 stty --save > $saved_state || fail=1
33 stty $(cat $saved_state) || fail=1
35 # Build a list of all boolean options stty accepts on this system.
36 # Don't depend on terminal width. Put each option on its own line,
37 # remove all non-boolean ones, remove 'parenb' and 'cread' explicitly,
38 # then remove any leading hyphens.
39 sed_del='/^speed/d;/^rows/d;/^columns/d;/ = /d;s/parenb//;s/cread//'
40 options=$(stty -a | tr -s ';' '\n' | sed "s/^ //;$sed_del;s/-//g")
42 # Take them in pairs, with and without the leading '-'.
43 for opt1 in $options; do
44 for opt2 in $options; do
46 stty $opt1 $opt2 || fail=1
48 if stty_reversible_query_ "$opt1" ; then
49 stty -$opt1 $opt2 || fail=1
51 if stty_reversible_query_ "$opt2" ; then
52 stty $opt1 -$opt2 || fail=1
54 if stty_reversible_query_ "$opt1" \
55 && stty_reversible_query_ "$opt2" ; then
56 stty -$opt1 -$opt2 || fail=1
61 stty $(cat $saved_state)