1TTY(1P) POSIX Programmer's Manual TTY(1P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
12 tty — return user's terminal name
13
15 tty
16
18 The tty utility shall write to the standard output the name of the ter‐
19 minal that is open as standard input. The name that is used shall be
20 equivalent to the string that would be returned by the ttyname() func‐
21 tion defined in the System Interfaces volume of POSIX.1‐2017.
22
24 The tty utility shall conform to the Base Definitions volume of
25 POSIX.1‐2017, Section 12.2, Utility Syntax Guidelines.
26
28 None.
29
31 While no input is read from standard input, standard input shall be
32 examined to determine whether or not it is a terminal, and, if so, to
33 determine the name of the terminal.
34
36 None.
37
39 The following environment variables shall affect the execution of tty:
40
41 LANG Provide a default value for the internationalization vari‐
42 ables that are unset or null. (See the Base Definitions vol‐
43 ume of POSIX.1‐2017, Section 8.2, Internationalization Vari‐
44 ables for the precedence of internationalization variables
45 used to determine the values of locale categories.)
46
47 LC_ALL If set to a non-empty string value, override the values of
48 all the other internationalization variables.
49
50 LC_CTYPE Determine the locale for the interpretation of sequences of
51 bytes of text data as characters (for example, single-byte as
52 opposed to multi-byte characters in arguments).
53
54 LC_MESSAGES
55 Determine the locale that should be used to affect the format
56 and contents of diagnostic messages written to standard error
57 and informative messages written to standard output.
58
59 NLSPATH Determine the location of message catalogs for the processing
60 of LC_MESSAGES.
61
63 Default.
64
66 If standard input is a terminal device, a pathname of the terminal as
67 specified by the ttyname() function defined in the System Interfaces
68 volume of POSIX.1‐2017 shall be written in the following format:
69
70
71 "%s\n", <terminal name>
72
73 Otherwise, a message shall be written indicating that standard input is
74 not connected to a terminal. In the POSIX locale, the tty utility shall
75 use the format:
76
77
78 "not a tty\n"
79
81 The standard error shall be used only for diagnostic messages.
82
84 None.
85
87 None.
88
90 The following exit values shall be returned:
91
92 0 Standard input is a terminal.
93
94 1 Standard input is not a terminal.
95
96 >1 An error occurred.
97
99 Default.
100
101 The following sections are informative.
102
104 This utility checks the status of the file open as standard input
105 against that of an implementation-defined set of files. It is possible
106 that no match can be found, or that the match found need not be the
107 same file as that which was opened for standard input (although they
108 are the same device).
109
111 None.
112
114 None.
115
117 None.
118
120 The Base Definitions volume of POSIX.1‐2017, Chapter 8, Environment
121 Variables, Section 12.2, Utility Syntax Guidelines
122
123 The System Interfaces volume of POSIX.1‐2017, isatty(), ttyname()
124
126 Portions of this text are reprinted and reproduced in electronic form
127 from IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
128 table Operating System Interface (POSIX), The Open Group Base Specifi‐
129 cations Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of
130 Electrical and Electronics Engineers, Inc and The Open Group. In the
131 event of any discrepancy between this version and the original IEEE and
132 The Open Group Standard, the original IEEE and The Open Group Standard
133 is the referee document. The original Standard can be obtained online
134 at http://www.opengroup.org/unix/online.html .
135
136 Any typographical or formatting errors that appear in this page are
137 most likely to have been introduced during the conversion of the source
138 files to man page format. To report such errors, see https://www.ker‐
139 nel.org/doc/man-pages/reporting_bugs.html .
140
141
142
143IEEE/The Open Group 2017 TTY(1P)