2015-02-01 09:11:44 +00:00
\section isatty isatty - test if a file descriptor is a tty.
2006-09-19 16:53:17 +00:00
\subsection isatty-synopsis Synopsis
2014-08-01 12:25:41 +00:00
\fish{synopsis}
2015-02-01 09:11:44 +00:00
isatty [FILE DESCRIPTOR]
2014-08-01 02:37:32 +00:00
\endfish
2006-09-19 16:53:17 +00:00
2013-04-22 01:13:18 +00:00
\subsection isatty-description Description
2014-08-19 12:41:23 +00:00
2015-02-01 09:11:44 +00:00
`isatty` tests if a file descriptor is a tty.
2006-09-19 16:53:17 +00:00
2015-02-01 09:11:44 +00:00
`FILE DESCRIPTOR` may be either the number of a file descriptor, or one of the strings `stdin`, `stdout`, or `stderr`.
If the specified file descriptor is a tty, the exit status of the command is zero. Otherwise, the exit status is non-zero. No messages are printed to standard error.
2013-04-22 01:13:18 +00:00
2014-08-19 12:41:23 +00:00
2014-01-08 03:57:49 +00:00
\subsection isatty-examples Examples
2006-09-19 16:53:17 +00:00
2014-01-08 03:57:49 +00:00
From an interactive shell, the commands below exit with a return value of zero:
2014-08-01 02:37:32 +00:00
\fish
2014-01-08 03:57:49 +00:00
isatty
isatty stdout
isatty 2
2015-02-01 09:11:44 +00:00
echo | isatty 1
2014-08-01 02:37:32 +00:00
\endfish
2014-01-08 03:57:49 +00:00
And these will exit non-zero:
2014-08-01 02:37:32 +00:00
\fish
2014-01-08 03:57:49 +00:00
echo | isatty
2015-02-01 09:11:44 +00:00
isatty 9
2014-01-08 03:57:49 +00:00
isatty stdout > file
isatty 2 2> file
2014-08-01 02:37:32 +00:00
\endfish