aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/psql/startup.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c
index 4730c733962..e4c0a7eacbf 100644
--- a/src/bin/psql/startup.c
+++ b/src/bin/psql/startup.c
@@ -666,15 +666,18 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts *options)
options->single_txn = true;
break;
case '?':
- /* Actual help option given */
- if (strcmp(argv[optind - 1], "-?") == 0)
+ if (optind <= argc &&
+ strcmp(argv[optind - 1], "-?") == 0)
{
+ /* actual help option given */
usage(NOPAGER);
exit(EXIT_SUCCESS);
}
- /* unknown option reported by getopt */
else
+ {
+ /* getopt error (unknown option or missing argument) */
goto unknown_option;
+ }
break;
case 1:
{