Search Postgresql Archives

Re: psql -f and PAGER

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2022-03-29 19:08:44 -0700, David G. Johnston wrote:
> On Tue, Mar 29, 2022 at 6:30 PM Paul Jungwirth <pj@xxxxxxxxxxxxxxxxxxxxxxxx>
> wrote:
> 
>     I noticed that this runs your pager:
> 
>          psql -f <(echo 'select * from pg_class;')
> 
>     but not this:
> 
>          echo 'select * from pg_class;' | psql
[...]
> 
> For both examples:
> pager defaults to on
> the output of the psql session is a terminal
> the full contents of pg_class are not going to fit on one terminal screen
> ergo, the output of select * from pg_class; should be piped to the pager in
> both cases

This is incomplete in the docs. The pager is also not called if stdin is
not a terminal (which makes sense - you couldn't control the pager). 

So 
    echo 'select * from pg_class;' | psql
doesn't call the pager. Neither do:
    psql -f <(echo 'select * from pg_class;') < /dev/null
    psql -f <(echo 'select * from pg_class;') > /dev/null

But 
    psql -f <(echo 'select * from pg_class;')
does, since both stdin and stdout are a terminal.

        hp

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp@xxxxxx         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Attachment: signature.asc
Description: PGP signature


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux