Document 'test -t' as alternative to tty(1)

This commit is contained in:
Gregory Chamberlain 2020-10-03 09:10:33 +01:00
parent 623a982953
commit 561a040ef4

View file

@ -1007,6 +1007,9 @@ This is an alternative to the `pwd` built-in.
## Check if input is from a terminal
This is an alternative to `tty` when you don't necessarily need to know
the terminal file name, just whether it is a terminal at all.
You can test whether file descriptor 0 (i.e. standard input) is open
on a terminal using `[ -t 0 ]`. This test fails if input is
redirected from a file (`<file`) or a pipe (`cmd|`).
@ -1033,6 +1036,9 @@ fi
## Check if output is to a terminal
This is an alternative to `tty` when you don't necessarily need to know
the terminal file name, just whether it is a terminal at all.
You can test whether file descriptor 1 (i.e. standard output) is open
on a terminal using `[ -t 1 ]`. This test fails if output is
redirected to a file (`>file`) or a pipe (`|cmd`).