Re: alternate psql file locations

Lists: pgsql-hackers
From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: alternate psql file locations
Date: 2011-12-31 15:52:02
Message-ID: 4EFF2FA2.6060404@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

It's not a big thing, but I just found myself in a shared environment
wanting to be able to set alternative locations for the psql startup
file and history. I know there's the HISTFILE variable, but I can't
easily set that automatically unless I can at least have my own .psqlrc.
ISTM it should be a fairly simple thing to provide these, via
environment variables. Is there general interest in such a thing?

cheers

andrew


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: alternate psql file locations
Date: 2011-12-31 20:17:59
Message-ID: 1325362624-sup-1403@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


Excerpts from Andrew Dunstan's message of sáb dic 31 12:52:02 -0300 2011:
> It's not a big thing, but I just found myself in a shared environment
> wanting to be able to set alternative locations for the psql startup
> file and history. I know there's the HISTFILE variable, but I can't
> easily set that automatically unless I can at least have my own .psqlrc.
> ISTM it should be a fairly simple thing to provide these, via
> environment variables. Is there general interest in such a thing?

I wanted such a thing mere two weeks ago ...

--
Álvaro Herrera <alvherre(at)commandprompt(dot)com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Aidan Van Dyk <aidan(at)highrise(dot)ca>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: alternate psql file locations
Date: 2011-12-31 21:26:19
Message-ID: CAC_2qU9K8UGDDVjA_DcCMVsca4379aY7DaPeT8-56MgJ3QT1Sg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, Dec 31, 2011 at 3:17 PM, Alvaro Herrera
<alvherre(at)commandprompt(dot)com> wrote:
>
> Excerpts from Andrew Dunstan's message of sáb dic 31 12:52:02 -0300 2011:
>> It's not a big thing, but I just found myself in a shared environment
>> wanting to be able to set alternative locations for the psql startup
>> file and history. I know there's the HISTFILE variable, but I can't
>> easily set that automatically unless I can at least have my own .psqlrc.
>> ISTM it should be a fairly simple thing to provide these, via
>> environment variables. Is there general interest in such a thing?
>
> I wanted such a thing mere two weeks ago ...

Generally when I've wanted these things, I just make a new "$HOME" in
my shared user home dir:

export HOME=$HOME/aidan

It's worked for things I've wanted, I haven't tried it for psql stuff....

a.

--
Aidan Van Dyk                                             Create like a god,
aidan(at)highrise(dot)ca                                       command like a king,
http://www.highrise.ca/                                   work like a slave.


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Aidan Van Dyk <aidan(at)highrise(dot)ca>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: alternate psql file locations
Date: 2012-01-01 21:05:34
Message-ID: 4F00CA9E.9000307@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 12/31/2011 04:26 PM, Aidan Van Dyk wrote:
> On Sat, Dec 31, 2011 at 3:17 PM, Alvaro Herrera
> <alvherre(at)commandprompt(dot)com> wrote:
>> Excerpts from Andrew Dunstan's message of sáb dic 31 12:52:02 -0300 2011:
>>> It's not a big thing, but I just found myself in a shared environment
>>> wanting to be able to set alternative locations for the psql startup
>>> file and history. I know there's the HISTFILE variable, but I can't
>>> easily set that automatically unless I can at least have my own .psqlrc.
>>> ISTM it should be a fairly simple thing to provide these, via
>>> environment variables. Is there general interest in such a thing?
>> I wanted such a thing mere two weeks ago ...
> Generally when I've wanted these things, I just make a new "$HOME" in
> my shared user home dir:
>
> export HOME=$HOME/aidan
>
> It's worked for things I've wanted, I haven't tried it for psql stuff....
>

Yeah, but it's a bit hacky. I might well not want $HOME reset. Here's a
small patch that does what I think would suit me and Alvaro.

cheers

andrew

Attachment Content-Type Size
psqlenv.patch text/x-patch 3.1 KB

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Aidan Van Dyk <aidan(at)highrise(dot)ca>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: alternate psql file locations
Date: 2012-01-02 16:18:47
Message-ID: 4F01D8E7.6020102@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 01/01/2012 04:05 PM, Andrew Dunstan wrote:
>
>
> On 12/31/2011 04:26 PM, Aidan Van Dyk wrote:
>> On Sat, Dec 31, 2011 at 3:17 PM, Alvaro Herrera
>> <alvherre(at)commandprompt(dot)com> wrote:
>>> Excerpts from Andrew Dunstan's message of sáb dic 31 12:52:02 -0300
>>> 2011:
>>>> It's not a big thing, but I just found myself in a shared environment
>>>> wanting to be able to set alternative locations for the psql startup
>>>> file and history. I know there's the HISTFILE variable, but I can't
>>>> easily set that automatically unless I can at least have my own
>>>> .psqlrc.
>>>> ISTM it should be a fairly simple thing to provide these, via
>>>> environment variables. Is there general interest in such a thing?
>>> I wanted such a thing mere two weeks ago ...
>> Generally when I've wanted these things, I just make a new "$HOME" in
>> my shared user home dir:
>>
>> export HOME=$HOME/aidan
>>
>> It's worked for things I've wanted, I haven't tried it for psql
>> stuff....
>>
>
>
> Yeah, but it's a bit hacky. I might well not want $HOME reset. Here's
> a small patch that does what I think would suit me and Alvaro.
>
>

Incidentally, this actually doesn't work anyway. psql gets the home path
from getpwuid() and ignores $HOME. You could argue that that's a bug,
but it's been that way for a long time.

cheers

andrew


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Aidan Van Dyk <aidan(at)highrise(dot)ca>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: alternate psql file locations
Date: 2012-08-27 02:13:18
Message-ID: 20120827021318.GA28780@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Jan 2, 2012 at 11:18:47AM -0500, Andrew Dunstan wrote:
> >>It's worked for things I've wanted, I haven't tried it for psql
> >>stuff....
> >>
> >
> >
> >Yeah, but it's a bit hacky. I might well not want $HOME reset.
> >Here's a small patch that does what I think would suit me and
> >Alvaro.
> >
> >
>
> Incidentally, this actually doesn't work anyway. psql gets the home
> path from getpwuid() and ignores $HOME. You could argue that that's
> a bug, but it's been that way for a long time.

So, do we want to fix this and honor $HOME?

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Aidan Van Dyk <aidan(at)highrise(dot)ca>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: alternate psql file locations
Date: 2012-08-27 02:21:05
Message-ID: 503AD991.6030300@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 08/26/2012 10:13 PM, Bruce Momjian wrote:
> On Mon, Jan 2, 2012 at 11:18:47AM -0500, Andrew Dunstan wrote:
>>>> It's worked for things I've wanted, I haven't tried it for psql
>>>> stuff....
>>>>
>>>
>>> Yeah, but it's a bit hacky. I might well not want $HOME reset.
>>> Here's a small patch that does what I think would suit me and
>>> Alvaro.
>>>
>>>
>> Incidentally, this actually doesn't work anyway. psql gets the home
>> path from getpwuid() and ignores $HOME. You could argue that that's
>> a bug, but it's been that way for a long time.
> So, do we want to fix this and honor $HOME?
>

Not really. Mangling it is a nasty hack anyway. Meanwhile see the
subsequent 9.2 feature (described thus in the release notes):

*

Provide environment variable overrides for psql history and startup
file locations (Andrew Dunstan)

Specifically, PSQL_HISTORY and PSQLRC determine these file names if set.

cheers

andrew