summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut2023-10-06 08:55:10 +0000
committerPeter Eisentraut2023-10-06 09:54:36 +0000
commitb4336515b0803b83a4d8f102006986e5863d2c49 (patch)
tree5484f23595febe46e418606a925e91545fb2c1e2
parentaec684ff0fb979d0245985fc0f84c07345a29e18 (diff)
Remove environment-variable-based defaults in psql --help
This seemed inconsistent with the --help output of other tools. Depending on the values, it can cause ugly formatting. Also, we're not getting the defaults from libpq, we're just emulating the methods libpq uses to derive these values, so they might not be 100% correct. Author: Atsushi Torikoshi <[email protected]> Discussion: https://www.postgresql.org/message-id/flat/[email protected]
-rw-r--r--src/bin/psql/help.c33
1 files changed, 4 insertions, 29 deletions
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index 12280c0e54..3b2d59e2ee 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -50,22 +50,10 @@
void
usage(unsigned short int pager)
{
- const char *env;
- const char *user;
- char *errstr;
PQExpBufferData buf;
int nlcount;
FILE *output;
- /* Find default user, in case we need it. */
- user = getenv("PGUSER");
- if (!user)
- {
- user = get_user_name(&errstr);
- if (!user)
- pg_fatal("%s", errstr);
- }
-
/*
* To avoid counting the output lines manually, build the output in "buf"
* and then count them.
@@ -77,13 +65,8 @@ usage(unsigned short int pager)
HELP0(" psql [OPTION]... [DBNAME [USERNAME]]\n\n");
HELP0("General options:\n");
- /* Display default database */
- env = getenv("PGDATABASE");
- if (!env)
- env = user;
HELP0(" -c, --command=COMMAND run only single command (SQL or internal) and exit\n");
- HELPN(" -d, --dbname=DBNAME database name to connect to (default: \"%s\")\n",
- env);
+ HELP0(" -d, --dbname=DBNAME database name to connect to\n");
HELP0(" -f, --file=FILENAME execute commands from file, then exit\n");
HELP0(" -l, --list list available databases, then exit\n");
HELP0(" -v, --set=, --variable=NAME=VALUE\n"
@@ -128,17 +111,9 @@ usage(unsigned short int pager)
" set record separator for unaligned output to zero byte\n");
HELP0("\nConnection options:\n");
- /* Display default host */
- env = getenv("PGHOST");
- HELPN(" -h, --host=HOSTNAME database server host or socket directory (default: \"%s\")\n",
- env ? env : _("local socket"));
- /* Display default port */
- env = getenv("PGPORT");
- HELPN(" -p, --port=PORT database server port (default: \"%s\")\n",
- env ? env : DEF_PGPORT_STR);
- /* Display default user */
- HELPN(" -U, --username=USERNAME database user name (default: \"%s\")\n",
- user);
+ HELP0(" -h, --host=HOSTNAME database server host or socket directory\n");
+ HELP0(" -p, --port=PORT database server port\n");
+ HELP0(" -U, --username=USERNAME database user name\n");
HELP0(" -w, --no-password never prompt for password\n");
HELP0(" -W, --password force password prompt (should happen automatically)\n");