diff options
author | Rob Landley <rob@landley.net> | 2023-04-17 18:05:47 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2023-04-17 18:05:47 -0500 |
commit | 9be9766df2c0e17602f900bfdef9d400eb5189d7 (patch) | |
tree | 7a75cbd98027fd8b09b414c34c413f287350fa0c | |
parent | 126c719dd250735f1c9517dfb6dcdfe02f347818 (diff) | |
download | toybox-9be9766df2c0e17602f900bfdef9d400eb5189d7.tar.gz |
Add test -T to check if fd is open. (Do we have a stdin?" A pipe counts.)
-rw-r--r-- | toys/posix/test.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/toys/posix/test.c b/toys/posix/test.c index f9a2bbbb..cdb13e2a 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 a TTY -T open --- Tests with one argument on each side of an operator: Two strings: @@ -109,6 +109,7 @@ 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; } |