Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit51b2c08

Browse files
committed
Tighten usage of PSQL_WATCH_PAGER.
Don't use PSQL_WATCH_PAGER when stdin/stdout are not a terminal.This corresponds to the restrictions on when other commands willuse [PSQL_]PAGER. There isn't a lot of sense in trying to use apager in non-interactive cases, and doing so allows an environmentsetting to break our tests.Also, ignore PSQL_WATCH_PAGER if it is set but empty or all-blank,for the same reasons we ignore such settings of [PSQL_]PAGER (seecommit18f8f78).No documentation change is really needed, since there is nothingsuggesting that these constraints on [PSQL_]PAGER didn't alreadyapply to PSQL_WATCH_PAGER too. But I rearranged the texta little to make it read more naturally (IMHO anyway).Per report from Pavel Stehule. Back-patch to v15 wherePSQL_WATCH_PAGER was introduced.Discussion:https://postgr.es/m/CAFj8pRDTwFzmEWdA-gdAcUh0ZnxUioSfTMre71WyB_wNJy-8gw@mail.gmail.com
1 parente32701b commit51b2c08

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

‎doc/src/sgml/ref/psql-ref.sgml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3120,8 +3120,21 @@ lo_import 152801
31203120
<listitem>
31213121
<para>
31223122
Controls use of a pager program for query and <application>psql</application>
3123-
help output. If the environment variable <envar>PSQL_PAGER</envar>
3124-
or <envar>PAGER</envar> is set, the output is piped to the
3123+
help output.
3124+
When the <literal>pager</literal> option is <literal>off</literal>, the pager
3125+
program is not used. When the <literal>pager</literal> option is
3126+
<literal>on</literal>, the pager is used when appropriate, i.e., when the
3127+
output is to a terminal and will not fit on the screen.
3128+
The <literal>pager</literal> option can also be set to <literal>always</literal>,
3129+
which causes the pager to be used for all terminal output regardless
3130+
of whether it fits on the screen. <literal>\pset pager</literal>
3131+
without a <replaceable class="parameter">value</replaceable>
3132+
toggles pager use on and off.
3133+
</para>
3134+
3135+
<para>
3136+
If the environment variable <envar>PSQL_PAGER</envar>
3137+
or <envar>PAGER</envar> is set, output to be paged is piped to the
31253138
specified program. Otherwise a platform-dependent default program
31263139
(such as <filename>more</filename>) is used.
31273140
</para>
@@ -3135,18 +3148,6 @@ lo_import 152801
31353148
<application>psql</application>'s output format (such as
31363149
<filename>pspg --stream</filename>).
31373150
</para>
3138-
3139-
<para>
3140-
When the <literal>pager</literal> option is <literal>off</literal>, the pager
3141-
program is not used. When the <literal>pager</literal> option is
3142-
<literal>on</literal>, the pager is used when appropriate, i.e., when the
3143-
output is to a terminal and will not fit on the screen.
3144-
The <literal>pager</literal> option can also be set to <literal>always</literal>,
3145-
which causes the pager to be used for all terminal output regardless
3146-
of whether it fits on the screen. <literal>\pset pager</literal>
3147-
without a <replaceable class="parameter">value</replaceable>
3148-
toggles pager use on and off.
3149-
</para>
31503151
</listitem>
31513152
</varlistentry>
31523153

@@ -4898,7 +4899,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line '
48984899
pager-related options of the <command>\pset</command> command.
48994900
These variables are examined in the order listed;
49004901
the first that is set is used.
4901-
Ifnone of them is set, the default is to use <literal>more</literal> on most
4902+
Ifneither of them is set, the default is to use <literal>more</literal> on most
49024903
platforms, but <literal>less</literal> on Cygwin.
49034904
</para>
49044905

‎src/bin/psql/command.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5197,14 +5197,20 @@ do_watch(PQExpBuffer query_buf, double sleep, int iter)
51975197

51985198
/*
51995199
* For \watch, we ignore the size of the result and always use the pager
5200-
* if PSQL_WATCH_PAGER is set. We also ignore the regular PSQL_PAGER or
5201-
* PAGER environment variables, because traditional pagers probably won't
5202-
* be very useful for showing a stream of results.
5200+
* as long as we're talking to a terminal and "\pset pager" is enabled.
5201+
* However, we'll only use the pager identified by PSQL_WATCH_PAGER. We
5202+
* ignore the regular PSQL_PAGER or PAGER environment variables, because
5203+
* traditional pagers probably won't be very useful for showing a stream
5204+
* of results.
52035205
*/
52045206
#ifndefWIN32
52055207
pagerprog=getenv("PSQL_WATCH_PAGER");
5208+
/* if variable is empty or all-white-space, don't use pager */
5209+
if (pagerprog&&strspn(pagerprog," \t\r\n")==strlen(pagerprog))
5210+
pagerprog=NULL;
52065211
#endif
5207-
if (pagerprog&&myopt.topt.pager)
5212+
if (pagerprog&&myopt.topt.pager&&
5213+
isatty(fileno(stdin))&&isatty(fileno(stdout)))
52085214
{
52095215
fflush(NULL);
52105216
disable_sigpipe_trap();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp