sbase/echo.c

31 lines
532 B
C
Raw Normal View History

2011-05-22 21:36:34 -04:00
/* See LICENSE file for copyright and license details. */
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
2011-05-23 20:13:34 -04:00
#include <unistd.h>
2011-05-22 21:36:34 -04:00
int
main(int argc, char *argv[])
{
bool nflag = false;
2011-05-23 20:13:34 -04:00
char c;
2011-05-22 21:36:34 -04:00
2011-05-23 20:13:34 -04:00
while((c = getopt(argc, argv, "n")) != -1)
switch(c) {
case 'n':
nflag = true;
break;
default:
exit(EXIT_FAILURE);
}
for(; optind < argc; optind++) {
fputs(argv[optind], stdout);
if(optind+1 < argc)
2011-05-22 21:36:34 -04:00
fputc(' ', stdout);
}
if(!nflag)
fputc('\n', stdout);
return EXIT_SUCCESS;
}