~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to tests/misc/stty.sh

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh
 
2
# Make sure stty can parse most of its options.
 
3
 
 
4
# Copyright (C) 1998-2012 Free Software Foundation, Inc.
 
5
 
 
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.
 
10
 
 
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.
 
15
 
 
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/>.
 
18
 
 
19
# Make sure there's a tty on stdin.
 
20
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 
21
print_ver_ stty
 
22
 
 
23
require_controlling_input_terminal_
 
24
trap '' TTOU # Ignore SIGTTOU
 
25
 
 
26
# Get the reversible settings from stty.c.
 
27
stty_reversible_init_
 
28
 
 
29
saved_state=.saved-state
 
30
stty --save > $saved_state || fail=1
 
31
stty $(cat $saved_state) || fail=1
 
32
 
 
33
# This would segfault prior to sh-utils-2.0j.
 
34
stty erase - || fail=1
 
35
 
 
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
 
40
 
 
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")
 
46
 
 
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
 
56
 
 
57
  stty $opt || fail=1
 
58
 
 
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; }
 
63
  fi
 
64
done
 
65
 
 
66
stty $(cat $saved_state)
 
67
 
 
68
Exit $fail