]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Return success exit code from "bsdcat --help" and print usage to stdout.
authorMike Kazantsev <mk.fraggod@gmail.com>
Tue, 8 Apr 2014 19:19:48 +0000 (01:19 +0600)
committerfraggod@sacrilege <mk.fraggod@gmail.com>
Tue, 8 Apr 2014 21:54:53 +0000 (03:54 +0600)
cat/bsdcat.c
cat/bsdcat.h

index 43122db761ab23bc17d28cbba6366e6cd3c3782c..e5e50e438feed38c153e83a59015859cec86c7fa 100644 (file)
@@ -39,12 +39,12 @@ char *bsdcat_current_path;
 
 
 void
-usage(void)
+usage(FILE *stream, int eval)
 {
        const char *p;
        p = lafe_getprogname();
-       fprintf(stderr, "Usage: %s [-h] [--help] [--version] [--] [filenames...]\n", p);
-       exit(1);
+       fprintf(stream, "Usage: %s [-h] [--help] [--version] [--] [filenames...]\n", p);
+       exit(eval);
 }
 
 static void
@@ -94,10 +94,14 @@ main(int argc, char **argv)
                        case '-':
                                if (strcmp(argv[optind], "--version") == 0)
                                        version();
-                               if (strcmp(argv[optind], "--help") != 0)
+                               if (strcmp(argv[optind], "--help") != 0) {
                                        lafe_warnc(0, "invalid option -- '%s'", argv[optind]);
+                                       usage(stderr, 1);
+                               }
+                       case 'h':
+                               usage(stdout, 0);
                        default:
-                               usage();
+                               usage(stderr, 1);
                }
        }
 
index 0f6e38e89445a3d5c6740f550ab93c21ea5d07f4..227e01acea7768379726aa05ffe6f741d3fa65a8 100644 (file)
@@ -34,7 +34,7 @@
 #include <archive.h>
 #include <archive_entry.h>
 
-void usage(void);
+void usage(FILE *stream, int eval);
 void bsdcat_next(void);
 void bsdcat_print_error(void);
 void bsdcat_read_to_stdout(char* filename);