Re: psql: small patch to correct filename formatting error in '\s FILE' output

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ian Lawrence Barwick <barwick(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: psql: small patch to correct filename formatting error in '\s FILE' output
Date: 2013-01-22 21:36:34
Message-ID: 27311.1358890594@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Ian Lawrence Barwick <barwick(at)gmail(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dickson S. Guedes 2013-01-22 21:53:35 Re: psql: small patch to correct filename formatting error in '\s FILE' output
Previous Message Andres Freund 2013-01-22 21:15:00 Re: Event Triggers: adding information