forked from bonsai/harakit
cat(1p): print errors to stderr
This commit is contained in:
parent
dd584b2886
commit
96d692d26e
14
src/cat.c
14
src/cat.c
@ -72,7 +72,7 @@ int main(int argc, char *argv[]) {
|
|||||||
u = true;
|
u = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("Usage: %s (-u) file...\n", argv[0]);
|
fprintf(stderr, "Usage: %s (-u) file...\n", argv[0]);
|
||||||
return EX_USAGE;
|
return EX_USAGE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -102,22 +102,22 @@ int main(int argc, char *argv[]) {
|
|||||||
} else if ((file = fopen(argv[i], "r")) == NULL) {
|
} else if ((file = fopen(argv[i], "r")) == NULL) {
|
||||||
switch (errno) {
|
switch (errno) {
|
||||||
case EACCES:
|
case EACCES:
|
||||||
printf("%s: %s: Permission denied.\n", argv[0], argv[i]);
|
fprintf(stderr, "%s: %s: Permission denied.\n", argv[0], argv[i]);
|
||||||
return EX_NOINPUT;
|
return EX_NOINPUT;
|
||||||
case EISDIR:
|
case EISDIR:
|
||||||
printf("%s: %s: Is a directory.\n", argv[0], argv[i]);
|
fprintf(stderr, "%s: %s: Is a directory.\n", argv[0], argv[i]);
|
||||||
return EX_NOINPUT;
|
return EX_NOINPUT;
|
||||||
case ELOOP:
|
case ELOOP:
|
||||||
printf("%s: %s: Is a symbolic link loop.\n", argv[0], argv[i]);
|
fprintf(stderr, "%s: %s: Is a symbolic link loop.\n", argv[0], argv[i]);
|
||||||
return EX_UNAVAILABLE;
|
return EX_UNAVAILABLE;
|
||||||
case EMFILE:
|
case EMFILE:
|
||||||
printf("%s: Internal error.\n", argv[0]);
|
fprintf(stderr, "%s: Internal error.\n", argv[0]);
|
||||||
return EX_SOFTWARE;
|
return EX_SOFTWARE;
|
||||||
case ENOENT: case ENOTDIR: case ENXIO:
|
case ENOENT: case ENOTDIR: case ENXIO:
|
||||||
printf("%s: %s: No such file or directory.\n", argv[0], argv[i]);
|
fprintf(stderr, "%s: %s: No such file or directory.\n", argv[0], argv[i]);
|
||||||
return EX_NOINPUT;
|
return EX_NOINPUT;
|
||||||
default:
|
default:
|
||||||
printf("%s: Unknown error.\n", argv[0]);
|
fprintf(stderr, "%s: Unknown error.\n", argv[0]);
|
||||||
return EX_UNAVAILABLE;
|
return EX_UNAVAILABLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user