mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-14 17:07:44 +00:00
60808a4820
Presently, `isatty` only works on a handful of keywords. Here it is rewritten to be able to take any path, device or fd number as an argument, and eliminates errors printed to stdout. Per discussion in #1228, using `builtin test -c` within a pipe to test special file descriptors is not viable, so this implementation specifcially uses `command test`. Additionally, a note has been added to the documentation of `test` regarding this potential aberration from the expected output of the test utility under the 'Standards' section.
29 lines
854 B
Text
29 lines
854 B
Text
\section isatty isatty - test if a file or file descriptor is a tty.
|
|
|
|
\subsection isatty-synopsis Synopsis
|
|
<tt>isatty [FILE | DEVICE | FILE DESCRIPTOR NUMBER]</tt>
|
|
|
|
\subsection isatty-description Description
|
|
<tt>isatty</tt> 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, <tt>standard input</tt> 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:
|
|
<pre>
|
|
isatty
|
|
isatty stdout
|
|
isatty 2
|
|
echo | isatty /dev/fd/1
|
|
</pre>
|
|
|
|
And these will exit non-zero:
|
|
<pre>
|
|
echo | isatty
|
|
isatty /dev/fd/9
|
|
isatty stdout > file
|
|
isatty 2 2> file
|
|
</pre>
|