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;
|
||||
break;
|
||||
default:
|
||||
printf("Usage: %s (-u) file...\n", argv[0]);
|
||||
fprintf(stderr, "Usage: %s (-u) file...\n", argv[0]);
|
||||
return EX_USAGE;
|
||||
}
|
||||
}
|
||||
@ -102,22 +102,22 @@ int main(int argc, char *argv[]) {
|
||||
} else if ((file = fopen(argv[i], "r")) == NULL) {
|
||||
switch (errno) {
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
case EMFILE:
|
||||
printf("%s: Internal error.\n", argv[0]);
|
||||
fprintf(stderr, "%s: Internal error.\n", argv[0]);
|
||||
return EX_SOFTWARE;
|
||||
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;
|
||||
default:
|
||||
printf("%s: Unknown error.\n", argv[0]);
|
||||
fprintf(stderr, "%s: Unknown error.\n", argv[0]);
|
||||
return EX_UNAVAILABLE;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user