NAME
tty — return
user’s terminal name
SYNOPSIS
tty |
Obsolescent |
Version: |
tty |
-s |
DESCRIPTION
The tty utility shall write to the
standard output the name of the terminal that is open as standard input. The
name that is used shall be equivalent to the string that would be returned
by the POSIX. 1 {8}
ttyname()
function.
OPTIONS
The tty utility shall conform to the
utility argument syntax guidelines described in 2.10.2. The following option
shall be supported by the implementation:
OPERANDS
None.
STANDARD INPUT
While no input is read from standard input, standard input shall be examined to determine whether or not it is a terminal, and/or to determine the name of the terminal.
INPUT FILES
None.
ENVIRONMENT VARIABLES
The following environment variables shall affect the execution of
tty:
LANG-
This variable shall determine the locale to use for the locale categories when both LC_ALL and the corresponding environment variable (beginning with LC_ ) do not specify a locale. See 2.6.
LC_ALL-
This variable shall determine the locale to be used to override any values for locale categories specified by the settings of LANG or any environment variables beginning with LC_.
LC_CTYPE-
For the obsolescent version, this variable shall determine the locale for the interpretation of sequences of bytes of text data as characters (e.g., single- versus multibyte characters in arguments).
LC_MESSAGES-
This variable shall determine the language in which messages should be written.
ASYNCHRONOUS EVENTS
Default.
STANDARD OUTPUT
If the −s option is specified, standard output shall not be
used. If the −s option is not specified and standard input is a
terminal device, a pathname of the terminal as specified by
POSIX. 1 {8}
ttyname()
shall be written in the following format: "%s\n", <terminal
name> Otherwise, a message shall be written indicating that standard
input is not connected to a terminal. In the POSIX Locale,
the tty utility shall use the format: "not a
tty \n"
STANDARD ERROR
Used only for diagnostic messages.
OUTPUT FILES
None.
EXTENDED DESCRIPTION
None.
EXIT STATUS
The tty utility shall exit with one of the
following values:
CONSEQUENCES OF ERRORS
Default.
RATIONALE
EXAMPLES
This utility checks the status of the file open as standard input against that of a system-defined set of files. It is possible that no match can be found, or that the match found need not be the same file as that which was opened for standard input (although they are the same device). The −s option is useful only if the exit code is wanted. It does not rely on the ability to form a valid pathname. The −s option was made obsolescent because the same functionality is provided by test -t 0, but not dropped completely because historical scripts depend on this form.
HISTORY OF DECISIONS MADE
The definition of tty was made more
explicit to explain the difference between a tty and
a pathname of a tty.