'sort +0.18446744073709551615R input' on 64 bit systems.
[bug introduced in coreutils-7.2]
+ tty now exits with status 4 with a special diagnostic if ttyname
+ fails even though standard input is a tty. Formerly it quietly
+ pretended that standard input was not a tty.
+ [This bug was present in "the beginning".]
+
** Improvements
stty supports setting arbitrary baud rates on supported systems,
Chris Sylvain csylvain@umm.edu
Chris Yeo cyeo@biking.org
Christi Alice Scarborough christi@chiark.greenend.org.uk
+Christian Brauner christian.brauner@canonical.com
Christian Harkort christian.harkort@web.de
Christian Jullien eligis@orange.fr
Christian Krackowizer ckrackowiz@std.schuler-ag.com
1 if standard input is a non-terminal file
2 if given incorrect arguments
3 if a write error occurs
+4 if the terminal's name cannot be determined
@end display
enum
{
TTY_STDIN_NOTTY = 1,
- TTY_FAILURE = 2,
- TTY_WRITE_ERROR = 3
+ TTY_USAGE = 2,
+ TTY_WRITE_ERROR = 3,
+ TTY_TTYNAME_FAILURE = 4
};
/* The official name of this program (e.g., no 'g' prefix). */
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
default:
- usage (TTY_FAILURE);
+ usage (TTY_USAGE);
}
}
if (optind < argc)
{
error (0, 0, _("extra operand %s"), quote (argv[optind]));
- usage (TTY_FAILURE);
+ usage (TTY_USAGE);
}
- errno = ENOENT;
-
if (silent)
return isatty (STDIN_FILENO) ? EXIT_SUCCESS : TTY_STDIN_NOTTY;
- int status = EXIT_SUCCESS;
+ int status;
char const *tty = ttyname (STDIN_FILENO);
- if (! tty)
+ if (tty)
+ status = EXIT_SUCCESS;
+ else
{
+ int ttyname_err = errno;
+ if (isatty (STDIN_FILENO))
+ error (TTY_TTYNAME_FAILURE, ttyname_err, "ttyname");
tty = _("not a tty");
status = TTY_STDIN_NOTTY;
}
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ tty
+tty_works_on_stdin=false
+
if test -t 0; then
- tty || fail=1
+ if tty; then
+ tty_works_on_stdin=true
+ else
+ test $? -eq 4 || fail=1
+ fi
tty -s || fail=1
fi
returns_ 2 tty -s a || fail=1
if test -w /dev/full && test -c /dev/full; then
- if test -t 0; then
+ if $tty_works_on_stdin; then
returns_ 3 tty >/dev/full || fail=1
fi
returns_ 3 tty </dev/null >/dev/full || fail=1