mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-12-01 06:53:39 +08:00
34 lines
864 B
Plaintext
34 lines
864 B
Plaintext
\section isatty isatty - test if a file or file descriptor is a tty.
|
|
|
|
\subsection isatty-synopsis Synopsis
|
|
\fish{synopsis}
|
|
isatty [FILE | DEVICE | FILE DESCRIPTOR NUMBER]
|
|
\endfish
|
|
|
|
\subsection isatty-description Description
|
|
|
|
`isatty` tests if a file or file descriptor is a tty. The argument may be in the form of a file path, device, or file descriptor number. Without an argument, `standard input` is implied.
|
|
|
|
If the resolved file descriptor is a tty, the command returns zero. Otherwise, the command exits one. No messages are printed to standard error.
|
|
|
|
|
|
\subsection isatty-examples Examples
|
|
|
|
From an interactive shell, the commands below exit with a return value of zero:
|
|
|
|
\fish
|
|
isatty
|
|
isatty stdout
|
|
isatty 2
|
|
echo | isatty /dev/fd/1
|
|
\endfish
|
|
|
|
And these will exit non-zero:
|
|
|
|
\fish
|
|
echo | isatty
|
|
isatty /dev/fd/9
|
|
isatty stdout > file
|
|
isatty 2 2> file
|
|
\endfish
|