diff options
author | pgen <p.gen.progs@gmail.com> | 2023-02-03 23:12:54 +0100 |
---|---|---|
committer | pgen <p.gen.progs@gmail.com> | 2023-02-03 23:12:54 +0100 |
commit | 6a1f442b986f52ecca5ebb12c2147eb694b5782e (patch) | |
tree | c15865091852cb7ba9a806f1a27374113b13a0cc | |
parent | 6061eb0c3fbbe8026e7692fd4e335da89dc6cad0 (diff) |
Improve usage display
Do not display the full usage if the input file cannot be read.
-rw-r--r-- | ctxopt.c | 10 | ||||
-rw-r--r-- | smenu.c | 4 |
2 files changed, 10 insertions, 4 deletions
@@ -478,7 +478,7 @@ fatal(errors e, char * errmsg) if (e == CTXOPTUNKPAR && *errmsg != '\0') ctxopt_disp_usage(continue_after); else - ctxopt_ctx_disp_usage(cur_state->ctx_name, continue_after); + ctxopt_ctx_disp_usage(NULL, continue_after); exit(e); /* Exit with the error id e as return code. */ } @@ -4196,7 +4196,13 @@ ctxopt_ctx_disp_usage(char * ctx_name, usage_behaviour action) if (!flags.display_usage_on_error) return; - ctx = locate_ctx(ctx_name); + ctx = NULL; + + if (ctx_name != NULL) + ctx = locate_ctx(ctx_name); + else + ctx = locate_ctx(cur_state->ctx_name); + if (ctx == NULL) fatal_internal("Unknown context %s.", ctx_name); @@ -7741,7 +7741,7 @@ main(int argc, char * argv[]) { fprintf(stderr, "The file \"%s\" does not exist or cannot be read.\n", rem_args[0]); - ctxopt_disp_usage(exit_after); + ctxopt_ctx_disp_usage(NULL, exit_after); exit(EXIT_FAILURE); /* Avoid a compiler warning. */ } } @@ -7756,7 +7756,7 @@ main(int argc, char * argv[]) fprintf(stderr, ", %s", rem_args[i]); fprintf(stderr, ".\n"); - ctxopt_disp_usage(exit_after); + ctxopt_ctx_disp_usage(NULL, exit_after); exit(EXIT_FAILURE); /* Avoid a compiler warning. */ } |