Patch (tiny): \cd (change dir) for psql [with feedback]

Started by Mark Hambyover 25 years ago3 messagesgeneralpatches
Jump to latest
#1Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Mark Hamby (#2)
generalpatches
Re: Patch (tiny): \cd (change dir) for psql [with feedback]

Seems interesting. We already have \c overloaded with stuff like
connect, copy, and copyright, so I guess another one wouldn't hurt. I
will keep this for 7.2. Thanks.

[ Charset ISO-8859-1 unsupported, converting... ]

(Sorry for the repost. I have amended my previous patch
with feedback that outputs the new current directory.)

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.

[ Attachment, skipping... ]

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

-- 
  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
#2Mark Hamby
mark@archer.leavenworth.army.mil
generalpatches

(Sorry for the repost. I have amended my previous patch
with feedback that outputs the new current directory.)

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.

Attachments:

cd-patch.difapplication/octet-stream; name=cd-patch.difDownload+23-0
#3Peter Eisentraut
peter_e@gmx.net
In reply to: Mark Hamby (#2)
generalpatches
Re: [GENERAL] Patch (tiny): \cd (change dir) for psql [with feedback]

Mark Hamby writes:

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.

This sounds like a good idea.

Problems with your patch:

1. You can't portably use getcwd(NULL, xxx).

2. You should test for !quiet before printing messages to stdout.

3. You should use scan_option() to read command arguments. See \connect
above your code (rather than \copy below).

Unless you manage to fix these issues, I will do it. :-)

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