Re: psql: present working directory

Поиск
Список
Период
Сортировка
От Brendan Jurd
Тема Re: psql: present working directory
Дата
Msg-id 37ed240d0611200645l5b70c8ddw5fb735e0d35a7b22@mail.gmail.com
обсуждение исходный текст
Ответ на Re: psql: present working directory  (Jerry Sievers <jerry@jerrysievers.com>)
Список pgsql-hackers
On 20 Nov 2006 08:24:48 -0500, Jerry Sievers <jerry@jerrysievers.com> wrote:
> "Brendan Jurd" <direvus@gmail.com> writes:
> > Is there any interest in having a backslash command to psql that
> > prints the current working directory?  This would nicely complement
> > the functionality offered by \cd.
>
> We have this through subshell invocation
>
> \!pwd
>
> HTH

Yep, that does the trick, and it is convenient.

I had a look at what \cd currently does if you give it no arguments.
I expected it to do nothing at all (since there is no output), but see
src/bin/psql/command.c lines 266 - 285.  Under win32 the working
directory is set to "/", on other systems it is set to the value of
the current user's home directory.

The intent seems to be to mimic the behaviour of "cd" at the shell.
Under Linux (at least), "cd" with no arguments at the shell does
indeed change to your home directory.  Personally I think printing out
the current directory would make more sense in the psql context, but
mimicking the shell certainly has value.

Maybe psql should print a line saying "Current directory was set to
'/home/you'." in this case?

Comments in the code point out that "cd" without arguments under
Windows normally prints out the current directory, so the chdir to "/"
isn't ideal, and would probably be trivial to change to mimic the
Windows command line behaviour.


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Teodor Sigaev
Дата:
Сообщение: Re: Tsearch + polish ispell + polish locale
Следующее
От: "Jonah H. Harris"
Дата:
Сообщение: Re: [GENERAL] Allowing SYSDATE to Work