Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 680359FA373 for ; Tue, 5 Dec 2006 13:41:09 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 06510-04 for ; Tue, 5 Dec 2006 13:41:02 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from momjian.us (momjian.us [70.90.9.53]) by postgresql.org (Postfix) with ESMTP id 71B559FA2CB for ; Tue, 5 Dec 2006 13:41:01 -0400 (AST) Received: (from bruce@localhost) by momjian.us (8.11.6/8.11.6) id kB5Hf0x06888; Tue, 5 Dec 2006 12:41:00 -0500 (EST) From: Bruce Momjian Message-Id: <200612051741.kB5Hf0x06888@momjian.us> Subject: Re: psql man page error? In-Reply-To: <1165319827.3839.146.camel@silverbirch.site> To: Simon Riggs Date: Tue, 5 Dec 2006 12:41:00 -0500 (EST) CC: pgsql-docs@postgresql.org X-Mailer: ELM [version 2.4ME+ PL123] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="US-ASCII" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/7 X-Sequence-Number: 3930 Simon Riggs wrote: > > On the psql man page there is an example of how to perform multiple line > psql script as part of the -c option description. > > The example given is > > echo "\x \\ select * from foo;" | psql > > which gives > > prompt> echo "\x \\ select * from foo;" | psql > Expanded display is on. > invalid command \ > > i.e. doesn't work on bash. With bash the command should be: > > echo -e "\x \n select * from foo;" | psql > > which gives > > prompt> echo -e "\x \n select * from foo;" | psql > Expanded display is on. > ERROR: relation "foo" does not exist > > Does this mean there are multiple forms of the echo command, or is this > example just wrong? Intersting. This example has been around since at least 2002. The SGML looks like this: psql, like this: echo "\x \\ select * from foo;" | psql. and I suppose the asumption was that the \\ would be at the end of the output line, but in fact both HTML and manual pages just put the \\ anywhere on the line. I think the proper fix is: psql, like this: echo -e "\\x\nSELECT * FROM foo;" | psql. I think all modern operating systems understand echo -e at this point. Change applied to HEAD and 8.2.X. -- Bruce Momjian bruce@momjian.us EnterpriseDB http://www.enterprisedb.com + If your life is a hard drive, Christ can be your backup. +