Add usage().

This commit is contained in:
Philippe Charnier 1997-08-18 07:30:15 +00:00
parent 0e879078f3
commit 759bde1062
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=28372
2 changed files with 22 additions and 8 deletions

View File

@ -33,7 +33,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)tty.1 8.1 (Berkeley) 6/6/93
.\" $Id$
.\" $Id: tty.1,v 1.4 1997/02/22 19:57:29 peter Exp $
.\"
.Dd June 6, 1993
.Dt TTY 1
@ -42,11 +42,11 @@
.Nm tty
.Nd return user's terminal name
.Sh SYNOPSIS
.Nm tty
.Nm
.Op Fl s
.Sh DESCRIPTION
The
.Nm tty
.Nm
utility writes the name of the terminal attached to standard input
to standard output.
The name that is written is the string returned by
@ -73,8 +73,8 @@ not a terminal, and >1 if an error occurs.
.Xr ttyname 3
.Sh STANDARDS
The
.Nm tty
function is expected to be
.Nm
utility is expected to be
.St -p1003.2
compatible.
.Sh HISTORY

View File

@ -32,17 +32,25 @@
*/
#ifndef lint
static char copyright[] =
static const char copyright[] =
"@(#) Copyright (c) 1988, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)tty.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
"$Id$";
#endif /* not lint */
#include <stdio.h>
#include <unistd.h>
static void usage __P((void));
int
main(argc, argv)
int argc;
char **argv;
@ -58,8 +66,7 @@ main(argc, argv)
break;
case '?':
default:
fputs("usage: tty [-s]\n", stderr);
exit(2);
usage();
}
t = ttyname(0);
@ -67,3 +74,10 @@ main(argc, argv)
puts(t ? t : "not a tty");
exit(t ? 0 : 1);
}
static void
usage()
{
fprintf(stderr, "usage: tty [-s]\n");
exit(2);
}