logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git/
commit: e8c9ef5f5f7f8247e57f8b1f251cc96eb0ff269a
parent 604787e02b2ad230af2861917848970a6484afda
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sat, 12 Apr 2025 20:35:04 +0200

test-cmd/tty: add back </dev/null and >/dev/null tests

Diffstat:

Mtest-cmd/tty.sh19+++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/test-cmd/tty.sh b/test-cmd/tty.sh @@ -3,20 +3,35 @@ # SPDX-License-Identifier: MPL-2.0 target="$(dirname "$0")/../cmd/tty" -plans=1 +plans=3 . "$(dirname "$0")/tap.sh" tty >/dev/null 2>/dev/null -case $? in +is_tty=$? + +out_devnull() { + "$target" "$@" >/dev/null +} + +case $is_tty in 0) t noargs '' "$(tty) " + t_cmd out_devnull '' out_devnull ;; 1) t --exit=1 noargs '' 'not a tty ' + t_cmd --exit=1 out_devnull '' out_devnull ;; *) skip noargs "system tty exited with $?" + skip out_devnull "system tty exited with $?" ;; esac + +in_devnull() { + "$target" "$@" </dev/null +} +t_cmd --exit=1 in_devnull 'not a tty +' in_devnull