diff --git a/src/bin/pg_waldump/t/001_basic.pl b/src/bin/pg_waldump/t/001_basic.pl index 8beac19eaff..7b33efc6299 100644 --- a/src/bin/pg_waldump/t/001_basic.pl +++ b/src/bin/pg_waldump/t/001_basic.pl @@ -340,11 +340,10 @@ sub test_pg_waldump my ($stdout, $stderr); my $result = IPC::Run::run [ - 'pg_waldump', + 'pg_waldump', @opts, '--start' => $startlsn, '--end' => $endlsn, '--path' => $path, - @opts ], '>' => \$stdout, '2>' => \$stderr; diff --git a/src/port/getopt_long.c b/src/port/getopt_long.c index 2e869fed58b..0a9a50189f1 100644 --- a/src/port/getopt_long.c +++ b/src/port/getopt_long.c @@ -137,8 +137,9 @@ retry: { if (place[namelen] == '=') optarg = place + namelen + 1; - else if (optind < argc - 1 && - has_arg == required_argument) + else if (has_arg == optional_argument) + optarg = NULL; + else if (optind < argc - 1) { optind++; optarg = argv[optind]; @@ -152,16 +153,14 @@ retry: return BADARG; } - if (opterr && has_arg == required_argument) + if (opterr) fprintf(stderr, "%s: option requires an argument -- %s\n", argv[0], place); place = EMSG; - if (has_arg == required_argument) - return BADCH; - optarg = NULL; + return BADCH; } } else