]>
git.ipfire.org Git - thirdparty/bash.git/blob - examples/loadables/tty.c
febf518ba4ee5fb025e43d1dfd5f0619bbc49d39
1 /* tty - return terminal name */
3 /* See Makefile for compilation details. */
6 Copyright (C) 1999-2009 Free Software Foundation, Inc.
8 This file is part of GNU Bash.
9 Bash is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 Bash is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Bash. If not, see <http://www.gnu.org/licenses/>.
28 #include "bashgetopt.h"
31 extern char *ttyname ();
40 reset_internal_getopt ();
42 while ((opt
= internal_getopt (list
, "s")) != -1)
59 puts (t
? t
: "not a tty");
60 return (t
? EXECUTION_SUCCESS
: EXECUTION_FAILURE
);
64 "Display terminal name.",
66 "tty writes the name of the terminal that is opened for standard",
67 "input to standard output. If the `-s' option is supplied, nothing",
68 "is written; the exit status determines whether or not the standard",
69 "input is connected to a tty.",
73 /* The standard structure describing a builtin command. bash keeps an array
74 of these structures. */
75 struct builtin tty_struct
= {
76 "tty", /* builtin name */
77 tty_builtin
, /* function implementing the builtin */
78 BUILTIN_ENABLED
, /* initial flags for builtin */
79 tty_doc
, /* array of long documentation strings. */
80 "tty [-s]", /* usage synopsis; becomes short_doc */
81 0 /* reserved for internal use */