aboutsummaryrefslogtreecommitdiffhomepage
path: root/doc_src/isatty.txt
blob: 33f0a6e7a2f3773eaad57df5d61f6fdfd51aa74c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
\section isatty isatty - test if a file or file descriptor is a tty.

\subsection isatty-synopsis Synopsis
\fish{syn}
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