summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Couzens2026-02-10 13:06:02 +0000
committerAlexander Couzens2026-03-12 22:32:29 +0000
commitb17c31f8a2fd5e788c2a9d3246d6ff1091902360 (patch)
treec179fb660b117b5f6e92239ea6796eb856c692f7
parente086664e6a570630e8feba889482f174a9a8715e (diff)
downloadjsonpath-b17c31f8a2fd5e788c2a9d3246d6ff1091902360.tar.gz
main: exit 1 on getopt() errors
When getopt() encounter an invalid or unknown argument, it prints an error. However jsonpath ignored those and continued anyways. getopt() will print the error message to stderr. Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
-rw-r--r--main.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/main.c b/main.c
index 1b56978..97e5dac 100644
--- a/main.c
+++ b/main.c
@@ -533,6 +533,10 @@ int main(int argc, char **argv)
case 'q':
fclose(stderr);
break;
+ case '?':
+ /* invalid or unknown. getopt() prints the error to stderr */
+ rv = 1;
+ goto out;
}
}