File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -142,6 +142,16 @@ main(int argc, char *argv[])
142142 DataDir = getenv ("PGDATA" );
143143 }
144144
145+ /* Complain if any arguments remain */
146+ if (optind < argc )
147+ {
148+ fprintf (stderr , _ ("%s: too many command-line arguments (first is \"%s\")\n" ),
149+ progname , argv [optind ]);
150+ fprintf (stderr , _ ("Try \"%s --help\" for more information.\n" ),
151+ progname );
152+ exit (1 );
153+ }
154+
145155 if (DataDir == NULL )
146156 {
147157 fprintf (stderr , _ ("%s: no data directory specified\n" ), progname );
Original file line number Diff line number Diff line change @@ -237,14 +237,25 @@ main(int argc, char *argv[])
237237 }
238238 }
239239
240- if (DataDir == NULL && optind == argc )
240+ if (DataDir == NULL && optind < argc )
241+ DataDir = argv [optind ++ ];
242+
243+ /* Complain if any arguments remain */
244+ if (optind < argc )
245+ {
246+ fprintf (stderr , _ ("%s: too many command-line arguments (first is \"%s\")\n" ),
247+ progname , argv [optind ]);
248+ fprintf (stderr , _ ("Try \"%s --help\" for more information.\n" ),
249+ progname );
250+ exit (1 );
251+ }
252+
253+ if (DataDir == NULL )
241254 {
242255 fprintf (stderr , _ ("%s: no data directory specified\n" ), progname );
243256 fprintf (stderr , _ ("Try \"%s --help\" for more information.\n" ), progname );
244257 exit (1 );
245258 }
246- if (DataDir == NULL )
247- DataDir = argv [optind ];
248259
249260 /*
250261 * Don't allow pg_resetxlog to be run as root, to avoid overwriting the
You can’t perform that action at this time.
0 commit comments