2019-03-31 17:05:09 +08:00
.. _cmd-isatty:
2018-12-17 09:39:33 +08:00
isatty - test if a file descriptor is a tty.
2019-01-03 12:10:47 +08:00
============================================
2018-12-17 09:39:33 +08:00
2018-12-18 09:58:24 +08:00
Synopsis
--------
2018-12-17 05:08:41 +08:00
isatty [FILE DESCRIPTOR]
2018-12-18 09:58:24 +08:00
2018-12-17 05:08:41 +08:00
2018-12-19 10:44:30 +08:00
Description
2019-01-03 12:10:47 +08:00
-----------
2018-12-17 05:08:41 +08:00
2018-12-20 04:02:45 +08:00
`` isatty `` tests if a file descriptor is a tty.
2018-12-17 05:08:41 +08:00
2018-12-20 04:02:45 +08:00
`` FILE DESCRIPTOR `` may be either the number of a file descriptor, or one of the strings `` stdin `` , `` stdout `` , or `` stderr `` .
2018-12-17 05:08:41 +08:00
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.
2018-12-19 10:44:30 +08:00
Examples
2019-01-03 12:10:47 +08:00
--------
2018-12-17 05:08:41 +08:00
From an interactive shell, the commands below exit with a return value of zero:
2018-12-19 11:14:04 +08:00
::
isatty
isatty stdout
isatty 2
echo | isatty 1
2018-12-17 05:08:41 +08:00
And these will exit non-zero:
2018-12-19 11:14:04 +08:00
::
echo | isatty
isatty 9
isatty stdout > file
isatty 2 2> file