From 156fac55c79e8c5e09972cf46d175024c0cedde9 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Tue, 17 Apr 2012 18:37:25 -0400 Subject: Don't override arguments set via options with positional arguments. A number of utility programs were rather careless about paremeters that can be set via both an option argument and a positional argument. This leads to results which can violate the Principal Of Least Astonishment. These changes refuse to use positional arguments to override settings that have been made via positional arguments. The changes are backpatched to all live branches. --- src/bin/initdb/initdb.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/bin/initdb/initdb.c') diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index 7ca4c934318..bbc79979303 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -2563,8 +2563,11 @@ main(int argc, char *argv[]) } - /* Non-option argument specifies data directory */ - if (optind < argc) + /* + * Non-option argument specifies data directory + * as long as it wasn't already specified with -D / --pgdata + */ + if (optind < argc && strlen(pg_data) == 0) { pg_data = xstrdup(argv[optind]); optind++; -- cgit v1.2.3