BSD 3 development
[unix-history] / usr / src / cmd / gets.c
CommitLineData
d12d704a
BJ
1#include <stdio.h>
2
3/*
4 * gets [ default ]
5 *
6 * read a line from standard input, echoing to std output
7 * if an error occurs just return "default"
8 * if no default and error exit abnormally
9 */
10main(argc, argv)
11 int argc;
12 char *argv[];
13{
14 char buf[BUFSIZ];
15
16 if (gets(buf) == NULL || buf[0] < ' ') {
17 if (argc == 1)
18 exit(1);
19 strcpy(buf,argv[1]);
20 }
21 printf("%s\n", buf);
22 exit(0);
23}