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

Commitbc478a0

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 parent95f2827 commitbc478a0

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
@@ -3039,8 +3039,21 @@ lo_import 152801
30393039
<listitem>
30403040
<para>
30413041
Controls use of a pager program for query and <application>psql</application>
3042-
help output. If the environment variable <envar>PSQL_PAGER</envar>
3043-
or <envar>PAGER</envar> is set, the output is piped to the
3042+
help output.
3043+
When the <literal>pager</literal> option is <literal>off</literal>, the pager
3044+
program is not used. When the <literal>pager</literal> option is
3045+
<literal>on</literal>, the pager is used when appropriate, i.e., when the
3046+
output is to a terminal and will not fit on the screen.
3047+
The <literal>pager</literal> option can also be set to <literal>always</literal>,
3048+
which causes the pager to be used for all terminal output regardless
3049+
of whether it fits on the screen. <literal>\pset pager</literal>
3050+
without a <replaceable class="parameter">value</replaceable>
3051+
toggles pager use on and off.
3052+
</para>
3053+
3054+
<para>
3055+
If the environment variable <envar>PSQL_PAGER</envar>
3056+
or <envar>PAGER</envar> is set, output to be paged is piped to the
30443057
specified program. Otherwise a platform-dependent default program
30453058
(such as <filename>more</filename>) is used.
30463059
</para>
@@ -3054,18 +3067,6 @@ lo_import 152801
30543067
<application>psql</application>'s output format (such as
30553068
<filename>pspg --stream</filename>).
30563069
</para>
3057-
3058-
<para>
3059-
When the <literal>pager</literal> option is <literal>off</literal>, the pager
3060-
program is not used. When the <literal>pager</literal> option is
3061-
<literal>on</literal>, the pager is used when appropriate, i.e., when the
3062-
output is to a terminal and will not fit on the screen.
3063-
The <literal>pager</literal> option can also be set to <literal>always</literal>,
3064-
which causes the pager to be used for all terminal output regardless
3065-
of whether it fits on the screen. <literal>\pset pager</literal>
3066-
without a <replaceable class="parameter">value</replaceable>
3067-
toggles pager use on and off.
3068-
</para>
30693070
</listitem>
30703071
</varlistentry>
30713072

@@ -4775,7 +4776,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line '
47754776
pager-related options of the <command>\pset</command> command.
47764777
These variables are examined in the order listed;
47774778
the first that is set is used.
4778-
Ifnone of them is set, the default is to use <literal>more</literal> on most
4779+
Ifneither of them is set, the default is to use <literal>more</literal> on most
47794780
platforms, but <literal>less</literal> on Cygwin.
47804781
</para>
47814782

‎src/bin/psql/command.c

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

50215021
/*
50225022
* For \watch, we ignore the size of the result and always use the pager
5023-
* if PSQL_WATCH_PAGER is set. We also ignore the regular PSQL_PAGER or
5024-
* PAGER environment variables, because traditional pagers probably won't
5025-
* be very useful for showing a stream of results.
5023+
* as long as we're talking to a terminal and "\pset pager" is enabled.
5024+
* However, we'll only use the pager identified by PSQL_WATCH_PAGER. We
5025+
* ignore the regular PSQL_PAGER or PAGER environment variables, because
5026+
* traditional pagers probably won't be very useful for showing a stream
5027+
* of results.
50265028
*/
50275029
#ifdefHAVE_POSIX_DECL_SIGWAIT
50285030
pagerprog=getenv("PSQL_WATCH_PAGER");
5031+
/* if variable is empty or all-white-space, don't use pager */
5032+
if (pagerprog&&strspn(pagerprog," \t\r\n")==strlen(pagerprog))
5033+
pagerprog=NULL;
50295034
#endif
5030-
if (pagerprog&&myopt.topt.pager)
5035+
if (pagerprog&&myopt.topt.pager&&
5036+
isatty(fileno(stdin))&&isatty(fileno(stdout)))
50315037
{
50325038
disable_sigpipe_trap();
50335039
pagerpipe=popen(pagerprog,"w");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp