TTY(1) General Commands Manual TTY(1)

ttyget path to current teletype

tty [-s]

Write the path of the tty connected to the standard input stream, or "not a tty", followed by a newline, to the standard output stream, and exit successfully only if it is.

, --silent, --quiet
Don't write anything, use isatty(3).

an error occurred,
the standard input stream is not attached to a teletype (or its name is undeterminable), and
otherwise.

ttyname(3)

Conforms to IEEE Std 1003.1-2008 (“POSIX.1”). The long flags are an extension, originating from the GNU system.

IEEE Std 1003.2-1992 (“POSIX.2”) specifies -s, but notes it as obsolescent, pointing toward the use of test -t 0 instead. IEEE Std 1003.1-2001 (“POSIX.1”) removes it.

Appears in the first edition of the UNIX Programmer's Manual as

tty  --  get tty name
writing "ttyn" or "not a tty" if the standard input file is not a typewriter (actually "Not a tty.").

Version 7 AT&T UNIX introduced -s, initially undocumented, and switched to the new ttyname(3) function, arriving at the tty of today.

June 9, 2023 voreutils pre-v0.0.0-latest