logo

utils-std

Collection of commonly available Unix tools
commit: fe179917b762d167e64582e81a2722e920ccbc90
parent 7cc2ea7f4ed4c9fae6789e94761d0e7a5c842e29
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Thu,  1 Aug 2024 03:39:23 +0200

test-cmd/tty.sh: Skip on system tty exiting with >1

For example in this particular case:
  $ tty
  tty: ttyname: No such file or directory
  [2] $

Which can't reasonably be handled due to error codes and the
formatting of failures being non-standard,
in fact $?=1 only got standardized in POSIX.1-2024.

Diffstat:

Mtest-cmd/tty.sh17++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/test-cmd/tty.sh b/test-cmd/tty.sh @@ -6,10 +6,17 @@ target="$(dirname "$0")/../cmd/tty" plans=1 . "$(dirname "$0")/tap.sh" -if tty >/dev/null 2>/dev/null; then - t noargs '' "$(tty) +tty >/dev/null 2>/dev/null +case $? in + 0) + t noargs '' "$(tty) " -else - t --exit=1 noargs '' 'not a tty + ;; + 1) + t --exit=1 noargs '' 'not a tty ' -fi + ;; + *) + skip noargs "system tty exited with $?" + ;; +esac