Re: psql: small patch to correct filename formatting error in '\s FILE' output - Mailing list pgsql-hackers

From Tom Lane
Subject Re: psql: small patch to correct filename formatting error in '\s FILE' output
Date
Msg-id 27311.1358890594@sss.pgh.pa.us
Whole thread Raw
In response to psql: small patch to correct filename formatting error in '\s FILE' output  (Ian Lawrence Barwick <barwick@gmail.com>)
Responses Re: psql: small patch to correct filename formatting error in '\s FILE' output
Re: psql: small patch to correct filename formatting error in '\s FILE' output
List pgsql-hackers
Ian Lawrence Barwick <barwick@gmail.com> writes:
> I've noticed a filename error in feedback messages from psql's '\s' command
> when saving the command line history to a file specified by an absolute
> filepath:

>   psql (9.2.2)
>   Type "help" for help.

>   pgdevel=# \s history.txt
>   Wrote history to file "./history.txt".
>   pgdevel=# \s /tmp/history.txt
>   Wrote history to file ".//tmp/history.txt".
>   pgdevel=# \cd /tmp
>   pgdevel=# \s /tmp/history.txt
>   Wrote history to file "/tmp//tmp/history.txt".

> The second and third '\s' commands display incorrect filepaths in the feedback
> message, despite writing correctly to the specified file.

I wonder why we don't just revert commit 0725065b --- this complaint
shows that it was quite poorly thought out, and I don't really see the
need for it anyway.  Aside from the complained-of bug, the code added to
the \cd command is entirely incapable of tracking through multiple \cd
operations properly.

If we did think that this specific backslash command needed to be able
to print something other than the filename as-entered, I'd be inclined
to just apply make_absolute_path() to the name, instead of relying on
inadequate dead-reckoning.  However, that would require making
make_absolute_path available in src/port/ or someplace, which seems
a bit more than this "feature" is worth.  Why should \s, and \s alone,
need to remind you where you're cd'd to?

Thoughts?
        regards, tom lane



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Event Triggers: adding information
Next
From: "Dickson S. Guedes"
Date:
Subject: Re: psql: small patch to correct filename formatting error in '\s FILE' output