aboutsummaryrefslogtreecommitdiff
path: root/src/bin/psql/input.c
diff options
context:
space:
mode:
authorAndrew Dunstan <andrew@dunslane.net>2012-03-03 16:39:26 -0500
committerAndrew Dunstan <andrew@dunslane.net>2012-03-03 16:39:26 -0500
commit34c978442c55dd13a3a8c6b90fd4380dad02f3da (patch)
tree898bacdf3a1253bb4e38158d0d379c82ea146a8d /src/bin/psql/input.c
parentb59ca98209d45f5689fe9de22a7429d4cf09d40c (diff)
downloadpostgresql-34c978442c55dd13a3a8c6b90fd4380dad02f3da.tar.gz
postgresql-34c978442c55dd13a3a8c6b90fd4380dad02f3da.zip
Provide environment overrides for psql file locations.
PSQL_HISTORY provides an alternative for the command history file, and PSQLRC provides an alternative location for the .psqlrc file.
Diffstat (limited to 'src/bin/psql/input.c')
-rw-r--r--src/bin/psql/input.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/bin/psql/input.c b/src/bin/psql/input.c
index d77a731c2ec..880e7e6511d 100644
--- a/src/bin/psql/input.c
+++ b/src/bin/psql/input.c
@@ -285,6 +285,15 @@ initializeInput(int flags)
history_lines_added = 0;
histfile = GetVariable(pset.vars, "HISTFILE");
+
+ if (histfile == NULL)
+ {
+ char * envhist;
+ envhist = getenv("PSQL_HISTORY");
+ if (envhist != NULL && strlen(envhist) > 0)
+ histfile = envhist;
+ }
+
if (histfile == NULL)
{
if (get_home_path(home))