File tree 2 files changed +24
-3
lines changed
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[])
142
142
DataDir = getenv ("PGDATA" );
143
143
}
144
144
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
+
145
155
if (DataDir == NULL )
146
156
{
147
157
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[])
237
237
}
238
238
}
239
239
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 )
241
254
{
242
255
fprintf (stderr , _ ("%s: no data directory specified\n" ), progname );
243
256
fprintf (stderr , _ ("Try \"%s --help\" for more information.\n" ), progname );
244
257
exit (1 );
245
258
}
246
- if (DataDir == NULL )
247
- DataDir = argv [optind ];
248
259
249
260
/*
250
261
* 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