echo.c (416B)
1 /* See LICENSE file for copyright and license details. */ 2 #include <stdio.h> 3 #include <stdlib.h> 4 5 #include "util.h" 6 7 static void 8 usage(void) 9 { 10 eprintf("usage: %s [-n] text\n", argv0); 11 } 12 13 int 14 main(int argc, char *argv[]) 15 { 16 int nflag = 0; 17 18 ARGBEGIN { 19 case 'n': 20 nflag = 1; 21 break; 22 default: 23 usage(); 24 } ARGEND; 25 26 for (; argc > 0; argc--, argv++) 27 putword(argv[0]); 28 if (!nflag) 29 putchar('\n'); 30 31 return 0; 32 }