tests: add test for locale decimal processing
[coreutils.git] / tests / misc / stty-pairs.sh
blob10797241bc1d4684b7d72b51a44985c5d6dd832c
1 #!/bin/sh
2 # Make sure stty can parse most of its options - in pairs [expensive].
4 # Copyright (C) 1998-2019 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 <https://www.gnu.org/licenses/>.
19 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
20 print_ver_ stty
22 expensive_
24 # Make sure there's a tty on stdin.
25 require_controlling_input_terminal_
26 require_trap_signame_
28 trap '' TTOU # Ignore SIGTTOU
30 # Get the reversible settings from stty.c.
31 stty_reversible_init_
33 saved_state=.saved-state
34 stty --save > $saved_state || fail=1
35 stty $(cat $saved_state) || fail=1
37 # Build a list of all boolean options stty accepts on this system.
38 # Don't depend on terminal width. Put each option on its own line,
39 # remove all non-boolean ones, remove 'parenb' and 'cread' explicitly,
40 # then remove any leading hyphens.
41 sed_del='/^speed/d;/^rows/d;/^columns/d;/ = /d;s/parenb//;s/cread//'
42 options=$(stty -a | tr -s ';' '\n' | sed "s/^ //;$sed_del;s/-//g")
44 # Take them in pairs, with and without the leading '-'.
45 for opt1 in $options; do
46 for opt2 in $options; do
48 stty $opt1 $opt2 || fail=1
50 if stty_reversible_query_ "$opt1" ; then
51 stty -$opt1 $opt2 || fail=1
53 if stty_reversible_query_ "$opt2" ; then
54 stty $opt1 -$opt2 || fail=1
56 if stty_reversible_query_ "$opt1" \
57 && stty_reversible_query_ "$opt2" ; then
58 stty -$opt1 -$opt2 || fail=1
60 done
61 done
63 stty $(cat $saved_state)
65 Exit $fail