sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

commit 171ef71c7407bffd8b418b1142b1ee4879e97259
parent 79e2f3ec19f97fd32ace43a3ec9d5aec376ed939
Author: Connor Lane Smith <cls@lubutu.com>
Date:   Thu, 31 May 2012 19:38:18 +0100

cat: ARGBEGIN
Diffstat:
Mcat.c | 18+++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/cat.c b/cat.c @@ -9,15 +9,19 @@ int main(int argc, char *argv[]) { FILE *fp; + int i; - if(getopt(argc, argv, "") != -1) - exit(EXIT_FAILURE); - if(optind == argc) + ARGBEGIN { + default: + eprintf("usage: %s [files...]\n", argv0); + } ARGEND; + + if(argc == 0) concat(stdin, "<stdin>", stdout, "<stdout>"); - else for(; optind < argc; optind++) { - if(!(fp = fopen(argv[optind], "r"))) - eprintf("fopen %s:", argv[optind]); - concat(fp, argv[optind], stdout, "<stdout>"); + else for(i = 0; i < argc; i++) { + if(!(fp = fopen(argv[i], "r"))) + eprintf("fopen %s:", argv[i]); + concat(fp, argv[i], stdout, "<stdout>"); fclose(fp); } return EXIT_SUCCESS;