Add support for '-' to cat
This chunk will need to be librarified at some point.
This commit is contained in:
parent
a62eda512c
commit
5dc02f757b
8
cat.c
8
cat.c
|
@ -15,6 +15,7 @@ usage(void)
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
char *p;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -27,11 +28,14 @@ main(int argc, char *argv[])
|
||||||
concat(stdin, "<stdin>", stdout, "<stdout>");
|
concat(stdin, "<stdin>", stdout, "<stdout>");
|
||||||
} else {
|
} else {
|
||||||
for(i = 0; i < argc; i++) {
|
for(i = 0; i < argc; i++) {
|
||||||
if(!(fp = fopen(argv[i], "r"))) {
|
p = argv[i];
|
||||||
|
if (argv[i][0] == '-')
|
||||||
|
p = "/dev/stdin";
|
||||||
|
if(!(fp = fopen(p, "r"))) {
|
||||||
weprintf("fopen %s:", argv[i]);
|
weprintf("fopen %s:", argv[i]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
concat(fp, argv[i], stdout, "<stdout>");
|
concat(fp, p, stdout, "<stdout>");
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user