(jm_FILE_SYSTEM_USAGE): Open-code what was a use of AS_IF.
[coreutils.git] / tests / stty / basic-1
blobba7dfabe2fc936c3f7be832103f8028a7e6244dd
1 #! /bin/sh
2 # Make sure stty can parse most of its options.
4 if test "$VERBOSE" = yes; then
5 set -x
6 stty --version
7 fi
9 # Make sure there's a tty on stdin.
10 . $srcdir/input-tty
12 # The following list of reversible options was generated with
13 # grep -w REV stty.c|sed -n '/^ {"/{s//REV_/;s/".*/=1/;p;}'|fmt
14 REV_parenb=1 REV_parodd=1 REV_hupcl=1 REV_hup=1 REV_cstopb=1 REV_cread=1
15 REV_clocal=1 REV_crtscts=1 REV_ignbrk=1 REV_brkint=1 REV_ignpar=1
16 REV_parmrk=1 REV_inpck=1 REV_istrip=1 REV_inlcr=1 REV_igncr=1 REV_icrnl=1
17 REV_ixon=1 REV_ixoff=1 REV_tandem=1 REV_iuclc=1 REV_ixany=1 REV_imaxbel=1
18 REV_opost=1 REV_olcuc=1 REV_ocrnl=1 REV_onlcr=1 REV_onocr=1 REV_onlret=1
19 REV_ofill=1 REV_ofdel=1 REV_isig=1 REV_icanon=1 REV_iexten=1 REV_echo=1
20 REV_echoe=1 REV_crterase=1 REV_echok=1 REV_echonl=1 REV_noflsh=1
21 REV_xcase=1 REV_tostop=1 REV_echoprt=1 REV_prterase=1 REV_echoctl=1
22 REV_ctlecho=1 REV_echoke=1 REV_crtkill=1 REV_evenp=1 REV_parity=1
23 REV_oddp=1 REV_nl=1 REV_cooked=1 REV_raw=1 REV_pass8=1 REV_litout=1
24 REV_cbreak=1 REV_decctlq=1 REV_tabs=1 REV_lcase=1 REV_LCASE=1
26 fail=0
28 saved_state=.saved-state
29 stty --save > $saved_state || fail=1
30 stty `cat $saved_state` || fail=1
32 # This would segfault prior to sh-utils-2.0j.
33 stty erase -
35 # Build a list of all boolean options stty accepts on this system.
36 options=`stty -a|tail +2|tr ';' '\012'|sed '/ = /d;s/^ //;s/-//g'`
38 # Take them one at a time, with and without the leading `-'.
39 for opt in $options; do
40 # `stty parenb' and `stty -parenb' fail with this message
41 # stty: standard input: unable to perform all requested operations
42 # on Linux 2.2.0-pre4 kernels, so skip those tests.
43 test $opt = parenb && continue
44 stty $opt || fail=1
46 # Likewise, `stty -cread' would fail, so skip that, too.
47 test $opt = cread && continue
48 rev=`eval echo "\\\$REV_$opt"`
49 if test -n "$rev"; then
50 stty -$opt || { fail=1; echo -$opt; }
52 done
54 if test -n "$RUN_LONG_TESTS"; then
55 # Take them in pairs.
56 for opt1 in $options; do
57 echo .|tr -d '\012'
58 for opt2 in $options; do
60 stty $opt1 $opt2 || fail=1
62 rev1=`eval echo "\\\$REV_$opt1"`
63 rev2=`eval echo "\\\$REV_$opt2"`
64 if test -n "$rev1"; then
65 stty -$opt1 $opt2 || fail=1
67 if test -n "$rev2"; then
68 stty $opt1 -$opt2 || fail=1
70 if test "$rev1$rev2" = 11; then
71 stty -$opt1 -$opt2 || fail=1
73 done
74 done
77 stty `cat $saved_state`
78 rm -f $saved_state
80 exit $fail