Re: psql man page error? - Mailing list pgsql-docs

From Bruce Momjian
Subject Re: psql man page error?
Date
Msg-id 200612051741.kB5Hf0x06888@momjian.us
Whole thread Raw
In response to psql man page error?  ("Simon Riggs" <simon@2ndquadrant.com>)
Responses Re: psql man page error?  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: psql man page error?  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-docs
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:

      <application>psql</application>, like this: <literal>echo "\x \\
      select * from foo;" | psql</literal>.

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:

      <application>psql</application>, like this: <literal>echo -e
      "\\x\nSELECT * FROM foo;" | psql</literal>.

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. +

pgsql-docs by date:

Previous
From: Jeff Frost
Date:
Subject: Re: psql man page error?
Next
From: Tom Lane
Date:
Subject: Re: psql man page error?