summaryrefslogtreecommitdiffstats
path: root/ctxopt.c
diff options
context:
space:
mode:
authorpgen <p.gen.progs@gmail.com>2023-02-03 23:12:54 +0100
committerpgen <p.gen.progs@gmail.com>2023-02-03 23:12:54 +0100
commit6a1f442b986f52ecca5ebb12c2147eb694b5782e (patch)
treec15865091852cb7ba9a806f1a27374113b13a0cc /ctxopt.c
parent6061eb0c3fbbe8026e7692fd4e335da89dc6cad0 (diff)
Improve usage display
Do not display the full usage if the input file cannot be read.
Diffstat (limited to 'ctxopt.c')
-rw-r--r--ctxopt.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/ctxopt.c b/ctxopt.c
index e5ba754..efc211c 100644
--- a/ctxopt.c
+++ b/ctxopt.c
@@ -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);