sbase/echo.c

30 lines
512 B
C
Raw Normal View History

2011-05-23 01:36:34 +00:00
/* See LICENSE file for copyright and license details. */
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
2011-05-24 00:13:34 +00:00
#include <unistd.h>
2011-05-23 01:36:34 +00:00
int
main(int argc, char *argv[])
{
bool nflag = false;
2011-05-24 00:13:34 +00:00
char c;
2011-05-23 01:36:34 +00:00
2011-05-24 00:13:34 +00: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-23 01:36:34 +00:00
fputc(' ', stdout);
}
if(!nflag)
fputc('\n', stdout);
return EXIT_SUCCESS;
}