diff options
author | Mike Kazantsev <mk.fraggod@gmail.com> | 2014-04-09 01:19:48 +0600 |
---|---|---|
committer | fraggod@sacrilege <mk.fraggod@gmail.com> | 2014-04-09 03:54:53 +0600 |
commit | 969b872849b1c4d7fe179ef6c442850e876aeeb6 (patch) | |
tree | 878381d1039f1e54c77ede51e8800ea90828281c | |
parent | cff02ba1f28888beef9c32b8bce9cdf2873b022e (diff) | |
download | libarchive-969b872849b1c4d7fe179ef6c442850e876aeeb6.tar.gz |
Return success exit code from "bsdcat --help" and print usage to stdout.
-rw-r--r-- | cat/bsdcat.c | 14 | ||||
-rw-r--r-- | cat/bsdcat.h | 2 |
2 files changed, 10 insertions, 6 deletions
diff --git a/cat/bsdcat.c b/cat/bsdcat.c index 43122db7..e5e50e43 100644 --- a/cat/bsdcat.c +++ b/cat/bsdcat.c @@ -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); } } diff --git a/cat/bsdcat.h b/cat/bsdcat.h index 0f6e38e8..227e01ac 100644 --- a/cat/bsdcat.h +++ b/cat/bsdcat.h @@ -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); |