summaryrefslogtreecommitdiff
path: root/tests/stty/basic-1
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1998-08-11 18:53:19 +0000
committerJim Meyering <jim@meyering.net>1998-08-11 18:53:19 +0000
commit3fce6c3270d03dd2df79ef129651ca047865f38e (patch)
treeac58846023119339334ef4ab5c6cb323aff2f1b2 /tests/stty/basic-1
parentba36aa0602bfcd5f739e20bed4a6beb2435edf99 (diff)
downloadcoreutils-3fce6c3270d03dd2df79ef129651ca047865f38e.tar.xz
.
Diffstat (limited to 'tests/stty/basic-1')
-rwxr-xr-xtests/stty/basic-167
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/stty/basic-1 b/tests/stty/basic-1
new file mode 100755
index 000000000..cd5471b01
--- /dev/null
+++ b/tests/stty/basic-1
@@ -0,0 +1,67 @@
+#! /bin/sh
+# Make sure stty can parse most of its options.
+
+reversible ()
+{
+ case $1 in
+ # The following list of reversible options was generated with
+ # grep -w REV stty.c |grep '{"' |sed 's/....//;s/".*//' \
+ # |fmt |tr ' ' '|' |sed 's/$/) ;;/'
+ parenb|parodd|hupcl|hup|cstopb|cread|clocal|crtscts|ignbrk|brkint|ignpar) ;;
+ parmrk|inpck|istrip|inlcr|igncr|icrnl|ixon|ixoff|tandem|iuclc|ixany) ;;
+ imaxbel|opost|olcuc|ocrnl|onlcr|onocr|onlret|ofill|ofdel|isig|icanon) ;;
+ iexten|echo|echoe|crterase|echok|echonl|noflsh|xcase|tostop|echoprt) ;;
+ prterase|echoctl|ctlecho|echoke|crtkill|evenp|parity|oddp|nl|cooked|raw) ;;
+ pass8|litout|cbreak|decctlq|tabs|lcase|LCASE) ;;
+
+ *) echo no; return;;
+ esac
+
+ echo yes;
+}
+
+: ${STTY=stty}
+
+if test "$VERBOSE" = yes; then
+ set -x
+ $RM --version
+fi
+
+saved_state=.saved-state
+$STTY --save > $saved_state || exit 1
+trap "status=$?; $STTY `cat $saved_state`; exit $status" 0 1 2 3 15
+$STTY `cat $saved_state` || exit 1
+
+# Build a list of all boolean options stty accepts on this system.
+options=`stty -a|tail +2|tr ';' '\012'|sed '/ = /d;s/^ //'|tr -s ' -' '\012'`
+
+# Take them one at a time, with and without the leading `-'.
+for opt in $options; do
+ $STTY $opt || exit 1
+ if test `reversible $opt` = yes; then
+ $STTY -$opt || exit 1
+ fi
+done
+
+# Take them in pairs.
+for opt1 in $options; do
+ echo .|tr -d '\012'
+ for opt2 in $options; do
+
+ $STTY $opt1 $opt2 || exit 1
+
+ test `reversible $opt1` = yes && rev1=yes || rev1=no
+ test `reversible $opt2` = yes && rev2=yes || rev2=no
+ if test $rev1 = yes; then
+ $STTY -$opt1 $opt2 || exit 1
+ fi
+ if test $rev2 = yes; then
+ $STTY $opt1 -$opt2 || exit 1
+ fi
+ if test "$rev1$rev2" = yesyes; then
+ $STTY -$opt1 -$opt2 || exit 1
+ fi
+ done
+done
+
+exit 0