Обсуждение: Patch (tiny): \cd (change dir) for psql.

Поиск
Список
Период
Сортировка

Patch (tiny): \cd (change dir) for psql.

От
"Mark Hamby"
Дата:
Here's a patch for a \cd (change dir) command in psql program.
It's very small and only adds a few lines.
Personally, I am surprised psql does not have this command.
It is EXTREMELY useful when \include'ing SQL scripts to set
up a database schema.

Hope you like,

Mark Hamby

P.S. I am not on the 'psql-patches' list, so responses should
be sent directly to me for more info or questions.


Вложения

Re: Patch (tiny): \cd (change dir) for psql.

От
missive@frontiernet.net (Lee Harr)
Дата:
On Mon, 26 Mar 2001 15:07:37 +0000 (UTC), Mark Hamby
<mark@archer.leavenworth.army.mil> wrote:
>
>
>Here's a patch for a \cd (change dir) command in psql program.
>It's very small and only adds a few lines.
>Personally, I am surprised psql does not have this command.
>It is EXTREMELY useful when \include'ing SQL scripts to set
>up a database schema.
>

It's a good idea. This is an itch I've needed scratched many times.





Re: Re: Patch (tiny): \cd (change dir) for psql.

От
Bruce Momjian
Дата:
> On Mon, 26 Mar 2001 15:07:37 +0000 (UTC), Mark Hamby
> <mark@archer.leavenworth.army.mil> wrote:
> >
> >
> >Here's a patch for a \cd (change dir) command in psql program.
> >It's very small and only adds a few lines.
> >Personally, I am surprised psql does not have this command.
> >It is EXTREMELY useful when \include'ing SQL scripts to set
> >up a database schema.
> >
>
> It's a good idea. This is an itch I've needed scratched many times.
>

Will be in 7.2.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: Re: Patch (tiny): \cd (change dir) for psql.

От
will trillich
Дата:
On Tue, Mar 27, 2001 at 09:52:05AM -0500, Bruce Momjian wrote:
> > On Mon, 26 Mar 2001 15:07:37 +0000 (UTC), Mark Hamby
> > <mark@archer.leavenworth.army.mil> wrote:
> > >
> > >
> > >Here's a patch for a \cd (change dir) command in psql program.
> > >It's very small and only adds a few lines.
> > >Personally, I am surprised psql does not have this command.
> > >It is EXTREMELY useful when \include'ing SQL scripts to set
> > >up a database schema.
> > >
> >
> > It's a good idea. This is an itch I've needed scratched many times.
> >
>
> Will be in 7.2.

and with it i'd imagine we'll also need

    # return to previous directory, for the lazy
    \cd -
    # show current working directory
    \cwd
    \pwd

of course, we could continue working the way we are now:

    somePsqlDb=> \q
    % cd /some/where/over/the/rainbow
    % psql mydata
    mydata=>

but why? :)

--
It is always hazardous to ask "Why?" in science, but it is often
interesting to do so just the same.
        -- Isaac Asimov, 'The Genetic Code'

will@serensoft.com
http://newbieDoc.sourceforge.net/ -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!

Re: Re: Patch (tiny): \cd (change dir) for psql.

От
Peter Eisentraut
Дата:
will trillich writes:

> and with it i'd imagine we'll also need
>
>     # return to previous directory, for the lazy
>     \cd -
>     # show current working directory
>     \cwd
>     \pwd

You can do this with

\!pwd

(Of course \!cd won't do what you want.  This situation is similar to an
ftp client.)

--
Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/


RE: Re: Patch (tiny): \cd (change dir) for psql.

От
Pruner Jan
Дата:
> You can do this with
>
> \!pwd
>
> (Of course \!cd won't do what you want.  This situation is
> similar to an
> ftp client.)
>
> --
> Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/
>
Why is not possible to run every bash command?
Something like '\ccd ..' for 'cd ..'  or  '\cpwd'  for 'pwd' etc.
It's pretty simple.

Jan Pruner
jan@pruner.cz

Re: Re: Patch (tiny): \cd (change dir) for psql.

От
will trillich
Дата:
On Thu, Mar 29, 2001 at 07:59:01AM +0200, Pruner Jan wrote:
> > You can do this with
> >
> > \!pwd
> >
> > (Of course \!cd won't do what you want.  This situation is
> > similar to an
> > ftp client.)
> >
> > --
> > Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/
>
> Why is not possible to run every bash command?
> Something like '\ccd ..' for 'cd ..'  or  '\cpwd'  for 'pwd' etc.

well, the bang-notation is already there: \!ls \!grep \!find
\!who \!last \!pwd

> It's pretty simple.

but it won't work for "cd" ... i know this one!

when a process forks (shield your eyes, everyone, give it some
privacy...) the 'child' inherits the same environment as the
'parent'. but after the fork, each is its own individual process
with its own environment. changing the directory of the parent
won't affect that of the child -- and VICE VERSA as well: namely,
spawning a child shell process, and then changing its default
working directory, will not matter one iota to the parent psql
process.

but you can fork off a quickie 'pwd' which will tell you what its
current directory is -- and given that there's no opportunity to
have it change its directory from the one it inherited from its
parent process, it'll match the 'pwd' of the parent 'psql'
process as well.

--
It is always hazardous to ask "Why?" in science, but it is often
interesting to do so just the same.
        -- Isaac Asimov, 'The Genetic Code'

will@serensoft.com
http://newbieDoc.sourceforge.net/ -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!