xref: /original-bsd/bin/echo/echo.c (revision 541b0a81)
1 /*
2  * Copyright (c) 1989, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 static char copyright[] =
10 "@(#) Copyright (c) 1989, 1993\n\
11 	The Regents of the University of California.  All rights reserved.\n";
12 #endif /* not lint */
13 
14 #ifndef lint
15 static char sccsid[] = "@(#)echo.c	8.1 (Berkeley) 05/31/93";
16 #endif /* not lint */
17 
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 
22 int
23 main(argc, argv)
24 	int argc;
25 	char *argv[];
26 {
27 	int nflag;
28 
29 	/* This utility may NOT do getopt(3) option parsing. */
30 	if (*++argv && !strcmp(*argv, "-n")) {
31 		++argv;
32 		nflag = 1;
33 	}
34 	else
35 		nflag = 0;
36 
37 	while (*argv) {
38 		(void)printf("%s", *argv);
39 		if (*++argv)
40 			putchar(' ');
41 	}
42 	if (!nflag)
43 		putchar('\n');
44 	exit(0);
45 }
46