Another minor tweak to psql startup: set the default values for the PROMPT1,

PROMPT2 and PROMPT3 variables before we read any of the settings specified
via the user on the command-line or in psqlrc, so that the latter can
override the former. Per original patch from Ingo van Lil, simpler fix
suggested by Tom Lane.
This commit is contained in:
Neil Conway 2004-10-08 11:24:19 +00:00
parent 79a831e50a
commit 9bf6effd8e

View File

@ -3,7 +3,7 @@
* *
* Copyright (c) 2000-2004, PostgreSQL Global Development Group * Copyright (c) 2000-2004, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.102 2004/10/06 08:20:58 neilc Exp $ * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.103 2004/10/08 11:24:19 neilc Exp $
*/ */
#include "postgres_fe.h" #include "postgres_fe.h"
@ -140,9 +140,13 @@ main(int argc, char *argv[])
SetVariable(pset.vars, "VERSION", PG_VERSION_STR); SetVariable(pset.vars, "VERSION", PG_VERSION_STR);
/* Default values for variables that are used in noninteractive cases */ /* Default values for variables */
SetVariableBool(pset.vars, "AUTOCOMMIT"); SetVariableBool(pset.vars, "AUTOCOMMIT");
SetVariable(pset.vars, "VERBOSITY", "default"); SetVariable(pset.vars, "VERBOSITY", "default");
SetVariable(pset.vars, "PROMPT1", DEFAULT_PROMPT1);
SetVariable(pset.vars, "PROMPT2", DEFAULT_PROMPT2);
SetVariable(pset.vars, "PROMPT3", DEFAULT_PROMPT3);
pset.verbosity = PQERRORS_DEFAULT; pset.verbosity = PQERRORS_DEFAULT;
pset.notty = (!isatty(fileno(stdin)) || !isatty(fileno(stdout))); pset.notty = (!isatty(fileno(stdin)) || !isatty(fileno(stdout)));
@ -300,11 +304,6 @@ main(int argc, char *argv[])
#endif #endif
} }
/* Default values for variables that are used in interactive case */
SetVariable(pset.vars, "PROMPT1", DEFAULT_PROMPT1);
SetVariable(pset.vars, "PROMPT2", DEFAULT_PROMPT2);
SetVariable(pset.vars, "PROMPT3", DEFAULT_PROMPT3);
if (!pset.notty) if (!pset.notty)
initializeInput(options.no_readline ? 0 : 1); initializeInput(options.no_readline ? 0 : 1);
if (options.action_string) /* -f - was used */ if (options.action_string) /* -f - was used */