2014-01-08 11:57:49 +08:00
|
|
|
\section isatty isatty - test if a file or file descriptor is a tty.
|
2006-09-20 00:53:17 +08:00
|
|
|
|
|
|
|
\subsection isatty-synopsis Synopsis
|
2014-08-01 20:25:41 +08:00
|
|
|
\fish{synopsis}
|
2014-08-01 10:37:32 +08:00
|
|
|
isatty [FILE | DEVICE | FILE DESCRIPTOR NUMBER]
|
|
|
|
\endfish
|
2006-09-20 00:53:17 +08:00
|
|
|
|
2013-04-22 09:13:18 +08:00
|
|
|
\subsection isatty-description Description
|
2014-08-01 10:37:32 +08:00
|
|
|
`isatty` tests if a file or file descriptor is a tty.
|
2014-01-08 11:57:49 +08:00
|
|
|
The argument may be in the form of a file path, device, or file descriptor
|
2014-08-01 10:37:32 +08:00
|
|
|
number. Without an argument, `standard input` is implied.
|
2006-09-20 00:53:17 +08:00
|
|
|
|
2014-01-08 11:57:49 +08:00
|
|
|
If the resolved file descriptor is a tty, the command returns zero. Otherwise, the command exits one. No messages are printed to standard error.
|
2013-04-22 09:13:18 +08:00
|
|
|
|
2014-01-08 11:57:49 +08:00
|
|
|
\subsection isatty-examples Examples
|
2006-09-20 00:53:17 +08:00
|
|
|
|
2014-01-08 11:57:49 +08:00
|
|
|
From an interactive shell, the commands below exit with a return value of zero:
|
2014-08-01 10:37:32 +08:00
|
|
|
|
|
|
|
\fish
|
2014-01-08 11:57:49 +08:00
|
|
|
isatty
|
|
|
|
isatty stdout
|
|
|
|
isatty 2
|
|
|
|
echo | isatty /dev/fd/1
|
2014-08-01 10:37:32 +08:00
|
|
|
\endfish
|
2014-01-08 11:57:49 +08:00
|
|
|
|
|
|
|
And these will exit non-zero:
|
2014-08-01 10:37:32 +08:00
|
|
|
|
|
|
|
\fish
|
2014-01-08 11:57:49 +08:00
|
|
|
echo | isatty
|
|
|
|
isatty /dev/fd/9
|
|
|
|
isatty stdout > file
|
|
|
|
isatty 2 2> file
|
2014-08-01 10:37:32 +08:00
|
|
|
\endfish
|