Re: [PROPOSAL] Make PSQLVAR on \getenv opitional

From: Matheus Alcantara <msalcantara(dot)dev(at)pm(dot)me>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PROPOSAL] Make PSQLVAR on \getenv opitional
Date: 2021-12-28 19:26:32
Message-ID: TsPD5AGHt3kdxVH1_MK9LHgzpz0-f2YGomR4QBxxsMb0mbXKUk5LJ-OibBr-U1ScXN-KjbuR6FSuvwtcWSTGzdXVKTPsqqeyZ-CZ57YnxMo=@pm.me
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> út 28. 12. 2021 v 19:51 odesílatel Matheus Alcantara <msalcantara(dot)dev(at)pm(dot)me> napsal:
>
>> Hi pgsql hackers, I was testing the new psql command \getenv introduced on commit 33d3eeadb2 and from a user perspective, I think that would be nice if the PSQLVAR parameter were optional, therefore when it is only necessary to view the value of the environment variable, the user just run \getenv, for example:
>>
>> \getenv PATH
>> /usr/local/sbin:/usr/local/bin:/usr/bin
>>
>> And when it is necessary to assign the environment variable in a variable, the user could execute like this:
>>
>> \getenv PATH myvar
>> \echo :myvar
>> /usr/local/sbin:/usr/local/bin:/usr/bin
>>
>> For this flexibility the order of parameters would need to be reversed, instead of \getenv PSQLVAR ENVVAR would be \getenv ENVVAR PSQLVAR.
>>
>> What do you guys think? I'm not a C expert but if this proposal is interesting I can write a patch.
>
> it is not consistent with other \g* commands. Maybe a new statement \senv ? But what is the use case? You can just press ^z and inside shell write echo $xxx, and then fg

I think that the basic use case would be just for debugging, instead call \getenv and them \echo, we could just use \getenv. I don't see any other advantages, It would just be to
write fewer commands. I think that ^z and then fg is a good alternative, since this behavior would be inconsistent.

> Regards
>
> Pavel
>
>> This is my first time sending an email here, so let me know if I doing something wrong.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Joel Jacobson 2021-12-28 19:26:36 Re: Foreign key joins revisited
Previous Message Pavel Stehule 2021-12-28 18:55:15 Re: [PROPOSAL] Make PSQLVAR on \getenv opitional