Continue concatenating files even if we can't open one.

This commit is contained in:
Matt Kraai 2000-09-27 03:01:40 +00:00
parent bbaef66b3f
commit e7c1af1e0d
3 changed files with 12 additions and 9 deletions

9
cat.c
View File

@ -26,20 +26,21 @@
extern int cat_main(int argc, char **argv) extern int cat_main(int argc, char **argv)
{ {
int status = EXIT_SUCCESS;
if (argc == 1) { if (argc == 1) {
print_file(stdin); print_file(stdin);
exit(TRUE); return status;
} }
while (--argc > 0) { while (--argc > 0) {
if(!(strcmp(*++argv, "-"))) { if(!(strcmp(*++argv, "-"))) {
print_file(stdin); print_file(stdin);
} else if (print_file_by_name(*argv) == FALSE) { } else if (print_file_by_name(*argv) == FALSE) {
perror(*argv); status = EXIT_FAILURE;
exit(FALSE);
} }
} }
return(TRUE); return status;
} }
/* /*

View File

@ -26,20 +26,21 @@
extern int cat_main(int argc, char **argv) extern int cat_main(int argc, char **argv)
{ {
int status = EXIT_SUCCESS;
if (argc == 1) { if (argc == 1) {
print_file(stdin); print_file(stdin);
exit(TRUE); return status;
} }
while (--argc > 0) { while (--argc > 0) {
if(!(strcmp(*++argv, "-"))) { if(!(strcmp(*++argv, "-"))) {
print_file(stdin); print_file(stdin);
} else if (print_file_by_name(*argv) == FALSE) { } else if (print_file_by_name(*argv) == FALSE) {
perror(*argv); status = EXIT_FAILURE;
exit(FALSE);
} }
} }
return(TRUE); return status;
} }
/* /*

View File

@ -1636,12 +1636,13 @@ extern int print_file_by_name(char *filename)
FILE *file; FILE *file;
file = fopen(filename, "r"); file = fopen(filename, "r");
if (file == NULL) { if (file == NULL) {
errorMsg("%s: %s\n", filename, strerror(errno));
return FALSE; return FALSE;
} }
print_file(file); print_file(file);
return TRUE; return TRUE;
} }
#endif /* BB_CAT || BB_LSMOD */ #endif /* BB_CAT */
#if defined BB_ECHO || defined BB_TR #if defined BB_ECHO || defined BB_TR
char process_escape_sequence(char **ptr) char process_escape_sequence(char **ptr)