sbase

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

commit 7ffe164106baa5a31a6b556308adae913221fd4e
parent 6449db8691e66ad53c276d41fb15179990d62aff
Author: sin <sin@2f30.org>
Date:   Thu, 13 Nov 2014 15:24:43 +0000

Modify argv[0] in place

Diffstat:
Mcat.c | 10++++------
1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/cat.c b/cat.c @@ -15,7 +15,6 @@ usage(void) int main(int argc, char *argv[]) { - char *p; FILE *fp; int ret = 0; @@ -31,15 +30,14 @@ main(int argc, char *argv[]) concat(stdin, "<stdin>", stdout, "<stdout>"); } else { for (; argc; argc--, argv++) { - p = argv[0]; if (argv[0][0] == '-') - p = "/dev/fd/0"; - if(!(fp = fopen(p, "r"))) { - weprintf("fopen %s:", p); + argv[0] = "/dev/fd/0"; + if(!(fp = fopen(argv[0], "r"))) { + weprintf("fopen %s:", argv[0]); ret = 1; continue; } - concat(fp, p, stdout, "<stdout>"); + concat(fp, argv[0], stdout, "<stdout>"); fclose(fp); } }