From bbd2d5a8fa3ff8265117f23a98111e9b3d53cef0 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 5 May 2023 02:09:10 -0500 Subject: [PATCH] Shell can test if a fd is open with "2>/dev/null /dev/console 1>&0 2>&1 + [ $$ -eq 1 ] && ! 2>/dev/null <0 && exec 0<>/dev/console 1>&0 2>&1 for i in ,fd /0,stdin /1,stdout /2,stderr do ln -sf /proc/self/fd${i/,*/} dev/${i/*,/}; done mkdir -p dev/shm diff --git a/toys/posix/test.c b/toys/posix/test.c index cdb13e2a..f9a2bbbb 100644 --- a/toys/posix/test.c +++ b/toys/posix/test.c @@ -28,7 +28,7 @@ config TEST STRING is: -n nonzero size -z zero size FD (integer file descriptor) is: - -t a TTY -T open + -t a TTY --- Tests with one argument on each side of an operator: Two strings: @@ -109,7 +109,6 @@ static int do_test(char **args, int *count) } else if (c == 'z') return !*args[1]; else if (c == 'n') return *args[1]; else if (c == 't') return isatty(atolx(args[1])); - else if (c == 'T') return -1 != fcntl(atolx(args[1]), F_GETFL); } return *count = 0; } -- 2.39.2