From e7c1af1e0dc1440483d7f195f15eb0df5cf70a04 Mon Sep 17 00:00:00 2001 From: Matt Kraai Date: Wed, 27 Sep 2000 03:01:40 +0000 Subject: Continue concatenating files even if we can't open one. --- cat.c | 9 +++++---- coreutils/cat.c | 9 +++++---- utility.c | 3 ++- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/cat.c b/cat.c index 51f1d27a6..151ce4e61 100644 --- a/cat.c +++ b/cat.c @@ -26,20 +26,21 @@ extern int cat_main(int argc, char **argv) { + int status = EXIT_SUCCESS; + if (argc == 1) { print_file(stdin); - exit(TRUE); + return status; } while (--argc > 0) { if(!(strcmp(*++argv, "-"))) { print_file(stdin); } else if (print_file_by_name(*argv) == FALSE) { - perror(*argv); - exit(FALSE); + status = EXIT_FAILURE; } } - return(TRUE); + return status; } /* diff --git a/coreutils/cat.c b/coreutils/cat.c index 51f1d27a6..151ce4e61 100644 --- a/coreutils/cat.c +++ b/coreutils/cat.c @@ -26,20 +26,21 @@ extern int cat_main(int argc, char **argv) { + int status = EXIT_SUCCESS; + if (argc == 1) { print_file(stdin); - exit(TRUE); + return status; } while (--argc > 0) { if(!(strcmp(*++argv, "-"))) { print_file(stdin); } else if (print_file_by_name(*argv) == FALSE) { - perror(*argv); - exit(FALSE); + status = EXIT_FAILURE; } } - return(TRUE); + return status; } /* diff --git a/utility.c b/utility.c index ae69baf4b..df2515c2b 100644 --- a/utility.c +++ b/utility.c @@ -1636,12 +1636,13 @@ extern int print_file_by_name(char *filename) FILE *file; file = fopen(filename, "r"); if (file == NULL) { + errorMsg("%s: %s\n", filename, strerror(errno)); return FALSE; } print_file(file); return TRUE; } -#endif /* BB_CAT || BB_LSMOD */ +#endif /* BB_CAT */ #if defined BB_ECHO || defined BB_TR char process_escape_sequence(char **ptr) -- cgit v1.2.3