Continue concatenating files even if we can't open one.
authorMatt Kraai <kraai@debian.org>
Wed, 27 Sep 2000 03:01:40 +0000 (03:01 -0000)
committerMatt Kraai <kraai@debian.org>
Wed, 27 Sep 2000 03:01:40 +0000 (03:01 -0000)
cat.c
coreutils/cat.c
utility.c

diff --git a/cat.c b/cat.c
index 51f1d27a64acdbf30d435d40b3095161024766e0..151ce4e61fa79ede7c05582e1262628a192f8d4d 100644 (file)
--- a/cat.c
+++ b/cat.c
 
 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;
 }
 
 /*
index 51f1d27a64acdbf30d435d40b3095161024766e0..151ce4e61fa79ede7c05582e1262628a192f8d4d 100644 (file)
 
 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;
 }
 
 /*
index ae69baf4b489f05246ebf2392d3cbf65642cc2bd..df2515c2bc8eb55599e427ec2b50811682effa5b 100644 (file)
--- 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)