>From 5ee9c8f7a6d3f2cec5eb4b086f05a60f67c8b052 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Wed, 30 Aug 2017 20:05:31 -0700 Subject: [PATCH 1/2] tests: avoid printf '0*d' construct unsupported by ash * tests/ln/sf-1.sh: Generate specific length with space padding which is supported. Reported by Assaf Gordon on Alpine Linux. --- tests/ln/sf-1.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ln/sf-1.sh b/tests/ln/sf-1.sh index c6dafdf..36d5b29 100755 --- a/tests/ln/sf-1.sh +++ b/tests/ln/sf-1.sh @@ -37,7 +37,7 @@ esac name_max=$(stat -f -c %l .) && test "$name_max" -lt $((1024*1024)) || name_max=1 # skip this portion of the test name_max_plus1=$(expr $name_max + 1) -long_name=$(printf '%0*d' $name_max_plus1 0) +long_name=$(printf '%*s' $name_max_plus1 | tr ' ' '0') for f in '' f; do ln -s$f missing ENOENT_link || fail=1 -- 2.9.3 >From 2f98755bb8c5af989d495999419f0db1097afc38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Wed, 30 Aug 2017 20:14:22 -0700 Subject: [PATCH 2/2] tty: don't distinguish input errors * src/tty.c (main): Don't distinguish ENOTTY from other errors, because isatty() doesn't portably distinguish errors. Solaris returns ENOENT for all input errors for example. Musl also returns ENOENT, and ENODEV may be returned as disscussed at: http://openwall.com/lists/musl/2017/04/06/6 * tests/misc/tty.sh: Adjust accordingly. --- src/tty.c | 9 ++------- tests/misc/tty.sh | 5 ++--- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/tty.c b/src/tty.c index 994b356..5e88c87 100644 --- a/src/tty.c +++ b/src/tty.c @@ -35,8 +35,7 @@ enum { TTY_STDIN_NOTTY = 1, TTY_FAILURE = 2, - TTY_WRITE_ERROR = 3, - TTY_STDIN_ERROR = 4 + TTY_WRITE_ERROR = 3 }; /* The official name of this program (e.g., no 'g' prefix). */ @@ -118,17 +117,13 @@ main (int argc, char **argv) errno = ENOENT; if (silent) - return (isatty (STDIN_FILENO) ? EXIT_SUCCESS - : (errno == ENOTTY || errno == EINVAL) ? TTY_STDIN_NOTTY - : TTY_STDIN_ERROR); + return isatty (STDIN_FILENO) ? EXIT_SUCCESS : TTY_STDIN_NOTTY; int status = EXIT_SUCCESS; char const *tty = ttyname (STDIN_FILENO); if (! tty) { - if (errno != ENOTTY && errno != EINVAL) - error (TTY_STDIN_ERROR, errno, _("standard input")); tty = _("not a tty"); status = TTY_STDIN_NOTTY; } diff --git a/tests/misc/tty.sh b/tests/misc/tty.sh index 904b5d6..aa3203b 100755 --- a/tests/misc/tty.sh +++ b/tests/misc/tty.sh @@ -27,6 +27,8 @@ fi returns_ 1 tty /dev/null || fail=1 +returns_ 1 tty -s <&- || fail=1 returns_ 2 tty a || fail=1 returns_ 2 tty -s a || fail=1 @@ -38,7 +40,4 @@ if test -w /dev/full && test -c /dev/full; then returns_ 3 tty /dev/full || fail=1 fi -returns_ 4 tty <&- 2>/dev/null || fail=1 -returns_ 4 tty -s <&- || fail=1 - Exit $fail -- 2.9.3