From 25600494ec85898e7bd7d0445e7f73cdc2b0eba5 Mon Sep 17 00:00:00 2001 From: Craig Barnes Date: Tue, 1 Jul 2025 11:33:45 +0100 Subject: Print usage info to stderr (instead of stdout), unless requested with -h --- src/encpipe.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src') 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 | -P } [-i ] [-o ]\n" @@ -23,7 +23,8 @@ usage(void) " -P, --passfile read password from \n" " -i, --in read input from \n" " -o, --out write output to \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); -- cgit v1.2.3-70-g09d2