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.
This commit is contained in:
parent
b59ca98209
commit
34c978442c
@ -3340,6 +3340,26 @@ PSQL_EDITOR_LINENUMBER_ARG='--line '
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><envar>PSQL_HISTORY</envar></term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Alternative location for the command history file. Tilde ("~") expansion is performed.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><envar>PSQLRC</envar></term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Alternative location of the user's .psqlrc file. Tilde ("~") expansion is performed.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><envar>SHELL</envar></term>
|
<term><envar>SHELL</envar></term>
|
||||||
|
|
||||||
@ -3390,6 +3410,11 @@ PSQL_EDITOR_LINENUMBER_ARG='--line '
|
|||||||
to set up the client or the server to taste (using the <command>\set
|
to set up the client or the server to taste (using the <command>\set
|
||||||
</command> and <command>SET</command> commands).
|
</command> and <command>SET</command> commands).
|
||||||
</para>
|
</para>
|
||||||
|
<para>
|
||||||
|
The location of the user's <filename>~/.psqlrc</filename> file can
|
||||||
|
also be set explicitly via the <envar>PSQLRC</envar> environment
|
||||||
|
setting.
|
||||||
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
@ -3411,6 +3436,11 @@ PSQL_EDITOR_LINENUMBER_ARG='--line '
|
|||||||
<filename>~/.psql_history</filename>, or
|
<filename>~/.psql_history</filename>, or
|
||||||
<filename>%APPDATA%\postgresql\psql_history</filename> on Windows.
|
<filename>%APPDATA%\postgresql\psql_history</filename> on Windows.
|
||||||
</para>
|
</para>
|
||||||
|
<para>
|
||||||
|
The location of the history file can
|
||||||
|
also be set explicitly via the <envar>PSQL_HISTORY</envar> environment
|
||||||
|
setting.
|
||||||
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
@ -285,6 +285,15 @@ initializeInput(int flags)
|
|||||||
history_lines_added = 0;
|
history_lines_added = 0;
|
||||||
|
|
||||||
histfile = GetVariable(pset.vars, "HISTFILE");
|
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 (histfile == NULL)
|
||||||
{
|
{
|
||||||
if (get_home_path(home))
|
if (get_home_path(home))
|
||||||
|
@ -591,6 +591,7 @@ process_psqlrc(char *argv0)
|
|||||||
char rc_file[MAXPGPATH];
|
char rc_file[MAXPGPATH];
|
||||||
char my_exec_path[MAXPGPATH];
|
char my_exec_path[MAXPGPATH];
|
||||||
char etc_path[MAXPGPATH];
|
char etc_path[MAXPGPATH];
|
||||||
|
char *envrc;
|
||||||
|
|
||||||
find_my_exec(argv0, my_exec_path);
|
find_my_exec(argv0, my_exec_path);
|
||||||
get_etc_path(my_exec_path, etc_path);
|
get_etc_path(my_exec_path, etc_path);
|
||||||
@ -598,7 +599,14 @@ process_psqlrc(char *argv0)
|
|||||||
snprintf(rc_file, MAXPGPATH, "%s/%s", etc_path, SYSPSQLRC);
|
snprintf(rc_file, MAXPGPATH, "%s/%s", etc_path, SYSPSQLRC);
|
||||||
process_psqlrc_file(rc_file);
|
process_psqlrc_file(rc_file);
|
||||||
|
|
||||||
if (get_home_path(home))
|
envrc = getenv("PSQLRC");
|
||||||
|
|
||||||
|
if (envrc != NULL && strlen(envrc) > 0)
|
||||||
|
{
|
||||||
|
expand_tilde(&envrc);
|
||||||
|
process_psqlrc_file(envrc);
|
||||||
|
}
|
||||||
|
else if (get_home_path(home))
|
||||||
{
|
{
|
||||||
snprintf(rc_file, MAXPGPATH, "%s/%s", home, PSQLRC);
|
snprintf(rc_file, MAXPGPATH, "%s/%s", home, PSQLRC);
|
||||||
process_psqlrc_file(rc_file);
|
process_psqlrc_file(rc_file);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user