[hackers] [sbase] Modify argv[0] in place || sin
commit 7ffe164106baa5a31a6b556308adae913221fd4e
Author: sin <sin_AT_2f30.org>
Date: Thu Nov 13 15:24:43 2014 +0000
Modify argv[0] in place
diff --git a/cat.c b/cat.c
index 67dac13..1af6dbb 100644
--- a/cat.c
+++ b/cat.c
_AT_@ -15,7 +15,6 @@ usage(void)
int
main(int argc, char *argv[])
{
- char *p;
FILE *fp;
int ret = 0;
_AT_@ -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);
}
}
Received on Thu Nov 13 2014 - 17:01:26 CET
This archive was generated by hypermail 2.3.0
: Thu Nov 13 2014 - 17:12:10 CET