Re: psql history and "-- lines"

From: Дилян Палаузов <dpa-postgres(at)aegee(dot)org>
To:
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: psql history and "-- lines"
Date: 2017-05-06 23:40:35
Message-ID: 01e0355e-381e-9732-7d4e-cbd0e6bfa710@aegee.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello,

the comment-begin should be useful in psql, even if the user has not
explicitly set comment-begin to be usefull (--):

Change comment-begin, if it has the libreadline default value:

diff --git a/src/bin/psql/input.c b/src/bin/psql/input.c
index 2359b11dcd..93da7f7c75 100644
--- a/src/bin/psql/input.c
+++ b/src/bin/psql/input.c
@@ -356,6 +356,8 @@ initializeInput(int flags)
/* these two things must be done in this order: */
initialize_readline();
rl_initialize();
+ if (!strcmp("#", rl_variable_value("comment-begin")))
+ rl_variable_bind("comment-begin", "--");

useHistory = true;
using_history();

Greetings
Дилян

On 05/07/2017 01:17 AM, Tom Lane wrote:
> =?UTF-8?B?0JTQuNC70Y/QvSDQn9Cw0LvQsNGD0LfQvtCy?= <dpa-postgres(at)aegee(dot)org> writes:
>> I expect that psql and the shell, e.g. bash, behave in the same way in
>> regards to history logs and until-the-current-line comments.
>
> I do not think that the shell necessarily provides a gold-plated precedent
> for us to follow. The language syntax it's dealing with is substantially
> different from SQL. Even ignoring that point, there are a lot of shell
> implementations with a lot of different interactive behaviors; who's to
> say that bash is the one true way?
>
>> + rl_variable_bind("comment-begin", "--");
>
> Interesting thought, but IIUC that's a setting that would be better left
> to the user's ~/.inputrc, or might indeed override something he's put
> there. I'm also dubious how well it works across all the versions of
> readline and libedit that are out there.
>
> Perhaps we could document suggested settings for people to put into
> ~/.inputrc:
>
> $if psql
> set comment-begin "-- "
> ... other things?
> $endif
>
>
> regards, tom lane
>

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Дилян Палаузов 2017-05-07 04:40:01 Re: psql history and "-- lines"
Previous Message Tom Lane 2017-05-06 23:17:42 Re: psql history and "-- lines"