aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bin/pg_controldata/pg_controldata.c10
-rw-r--r--src/bin/pg_resetxlog/pg_resetxlog.c17
2 files changed, 24 insertions, 3 deletions
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index dd68f793c3d..d0cf039f42a 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -142,6 +142,16 @@ main(int argc, char *argv[])
DataDir = getenv("PGDATA");
}
+ /* Complain if any arguments remain */
+ if (optind < argc)
+ {
+ fprintf(stderr, _("%s: too many command-line arguments (first is \"%s\")\n"),
+ progname, argv[optind]);
+ fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
+ progname);
+ exit(1);
+ }
+
if (DataDir == NULL)
{
fprintf(stderr, _("%s: no data directory specified\n"), progname);
diff --git a/src/bin/pg_resetxlog/pg_resetxlog.c b/src/bin/pg_resetxlog/pg_resetxlog.c
index 028a1f05665..f4c1eafc67c 100644
--- a/src/bin/pg_resetxlog/pg_resetxlog.c
+++ b/src/bin/pg_resetxlog/pg_resetxlog.c
@@ -237,14 +237,25 @@ main(int argc, char *argv[])
}
}
- if (DataDir == NULL && optind == argc)
+ if (DataDir == NULL && optind < argc)
+ DataDir = argv[optind++];
+
+ /* Complain if any arguments remain */
+ if (optind < argc)
+ {
+ fprintf(stderr, _("%s: too many command-line arguments (first is \"%s\")\n"),
+ progname, argv[optind]);
+ fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
+ progname);
+ exit(1);
+ }
+
+ if (DataDir == NULL)
{
fprintf(stderr, _("%s: no data directory specified\n"), progname);
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
exit(1);
}
- if (DataDir == NULL)
- DataDir = argv[optind];
/*
* Don't allow pg_resetxlog to be run as root, to avoid overwriting the