diff options
| author | 2025-07-01 11:33:45 +0100 | |
|---|---|---|
| committer | 2025-07-01 11:33:45 +0100 | |
| commit | 25600494ec85898e7bd7d0445e7f73cdc2b0eba5 (patch) | |
| tree | 11d978d7db4e747977b7b13f1aab79104c683689 /src | |
| parent | 7a3ba4bbee98b81e44617c10d5727992dbd13e12 (diff) | |
| download | tweetpipe-25600494ec85898e7bd7d0445e7f73cdc2b0eba5.tar.gz | |
Print usage info to stderr (instead of stdout), unless requested with -h
Diffstat (limited to 'src')
| -rw-r--r-- | src/encpipe.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/encpipe.c b/src/encpipe.c index 7a2b8ff..183a14a 100644 --- a/src/encpipe.c +++ b/src/encpipe.c @@ -8,9 +8,9 @@ static struct option getopt_long_options[] = { static const char *getopt_options = "hdeGi:o:p:P:"; static void -usage(void) +usage(FILE *stream) { - puts( + fputs( "Usage:\n" " encpipe -G\n" " encpipe {-e | -d} {-p <string> | -P <file>} [-i <file>] [-o <file>]\n" @@ -23,7 +23,8 @@ usage(void) " -P, --passfile <file> read password from <file>\n" " -i, --in <file> read input from <file>\n" " -o, --out <file> write output to <file>\n" - " -h, --help print this message"); + " -h, --help print this message\n", + stream); exit(2); } @@ -230,6 +231,9 @@ options_parse(Context *ctx, int argc, char *argv[]) case 'G': passgen(); break; /* NOTREACHED */ + case 'h': + usage(stdout); + break; /* NOTREACHED */ case 'i': ctx->in = optarg; break; @@ -243,11 +247,11 @@ options_parse(Context *ctx, int argc, char *argv[]) read_password_file(ctx, optarg); break; default: - usage(); + usage(stderr); } } if (ctx->encrypt == -1) { - usage(); + usage(stderr); } if (ctx->has_key == 0) { read_password_from_terminal(ctx); |