diff options
author | Dr. David von Oheimb <David.von.Oheimb@siemens.com> | 2021-01-07 10:16:12 +0100 |
---|---|---|
committer | Dr. David von Oheimb <dev@ddvo.net> | 2021-01-11 19:39:49 +0100 |
commit | 678cae0295e3fe600edc049742b8c765a58edebc (patch) | |
tree | ee4a876c65b769e987856cb440e4e9bd694333fc /apps/openssl.c | |
parent | APPS: Fix confusion between program and app/command name used in diagnostic/h... (diff) | |
download | openssl-678cae0295e3fe600edc049742b8c765a58edebc.tar.xz openssl-678cae0295e3fe600edc049742b8c765a58edebc.zip |
APPS: Print help also on -h and --h; print high-level help when no cmd given
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/13799)
Diffstat (limited to 'apps/openssl.c')
-rw-r--r-- | apps/openssl.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/apps/openssl.c b/apps/openssl.c index 0c95a7585e..b61ed5f81d 100644 --- a/apps/openssl.c +++ b/apps/openssl.c @@ -237,6 +237,7 @@ int main(int argc, char *argv[]) char *pname; const char *fname; ARGS arg; + int global_help = 0; int ret = 0; arg.argv = NULL; @@ -277,18 +278,21 @@ int main(int argc, char *argv[]) f.name = pname; fp = lh_FUNCTION_retrieve(prog, &f); if (fp == NULL) { - /* We assume we've been called as 'openssl cmd' */ + /* We assume we've been called as 'openssl ...' */ + global_help = argc > 1 + && (strcmp(argv[1], "-help") == 0 || strcmp(argv[1], "--help") == 0 + || strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--h") == 0); argc--; argv++; - opt_appname(argv[0]); + opt_appname(argc == 1 || global_help ? "help" : argv[0]); } else { argv[0] = pname; } /* If there's a command, run with that, otherwise "help". */ - ret = argc > 0 - ? do_cmd(prog, argc, argv) - : do_cmd(prog, 1, help_argv); + ret = argc == 0 || global_help + ? do_cmd(prog, 1, help_argv) + : do_cmd(prog, argc, argv); end: OPENSSL_free(default_config_file); |