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 0c090d15c2e..142ec76e10f 100644
--- a/src/bin/psql/startup.c
+++ b/src/bin/psql/startup.c
@@ -571,15 +571,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:
{