From 9a2a61ca289aeee256e104dda807431380eba319 Mon Sep 17 00:00:00 2001 From: Onur Gündüz Date: Wed, 17 Jun 2026 03:29:44 +0200 Subject: cli: reject unknown --options instead of treating them as text --- src/cli.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/cli.c') diff --git a/src/cli.c b/src/cli.c index 2729c25..0e3ed7d 100644 --- a/src/cli.c +++ b/src/cli.c @@ -647,6 +647,18 @@ int main(int argc, char *argv[]) { else if (!strcmp(f, "-h") || !strcmp(f, "--help")) { print_usage(prog); return 0; + } else if (!strcmp(f, "--")) { + /* End of options: everything after is positional text, even if it + * starts with a dash. */ + arg_start++; + break; + } else if (f[0] == '-' && f[1] == '-') { + /* An unrecognized --option is a hard error, not silently-embedded + * text. Catches typos and stale flags (e.g. the removed --backend) + * loudly instead of running the default path or embedding the flag. */ + fprintf(stderr, "unknown option: %s\n", f); + print_usage(prog); + return 1; } else break; arg_start++; -- cgit v1.3.1