mirror of
https://github.com/postgres/postgres.git
synced 2025-08-25 20:23:07 +03:00
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.
This commit is contained in:
@@ -91,14 +91,24 @@ main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* We set dbname from positional arguments if it is not
|
||||
* already set by option arguments -d. If not doing
|
||||
* listlangs, positional dbname must follow positional
|
||||
* langname.
|
||||
*/
|
||||
|
||||
if (argc - optind > 0)
|
||||
{
|
||||
if (listlangs)
|
||||
dbname = argv[optind++];
|
||||
{
|
||||
if (dbname == NULL)
|
||||
dbname = argv[optind++];
|
||||
}
|
||||
else
|
||||
{
|
||||
langname = argv[optind++];
|
||||
if (argc - optind > 0)
|
||||
if (argc - optind > 0 && dbname == NULL)
|
||||
dbname = argv[optind++];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user