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

Commit5e8304f

Browse files
committed
In psql, use PSQL_PAGER in preference to PAGER, if it's set.
This allows the user's environment to set up a psql-specific choiceof pager, in much the same way that we provide PSQL_EDITOR to allowa psql-specific override of the more widely known EDITOR variable.Pavel Stehule, reviewed by Thomas MunroDiscussion:https://postgr.es/m/CAFj8pRD3RRk9S1eRbnGm_T6brc3Ss5mohraNzTSJquzx+pmtKA@mail.gmail.com
1 parentebd346c commit5e8304f

File tree

4 files changed

+39
-27
lines changed

4 files changed

+39
-27
lines changed

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

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2665,10 +2665,10 @@ lo_import 152801
26652665
<listitem>
26662666
<para>
26672667
Controls use of a pager program for query and <application>psql</>
2668-
help output. If the environment variable <envar>PAGER</envar>
2669-
is set, the output is piped to the specified program.
2670-
Otherwise a platform-dependent default(such as
2671-
<filename>more</filename>) is used.
2668+
help output.If the environment variable <envar>PSQL_PAGER</envar>
2669+
or <envar>PAGER</envar>is set, the output is piped to the
2670+
specified program.Otherwise a platform-dependent defaultprogram
2671+
(such as<filename>more</filename>) is used.
26722672
</para>
26732673

26742674
<para>
@@ -4106,21 +4106,6 @@ $endif
41064106
</listitem>
41074107
</varlistentry>
41084108

4109-
<varlistentry>
4110-
<term><envar>PAGER</envar></term>
4111-
4112-
<listitem>
4113-
<para>
4114-
If the query results do not fit on the screen, they are piped
4115-
through this command. Typical values are
4116-
<literal>more</literal> or <literal>less</literal>. The default
4117-
is platform-dependent. Use of the pager can be disabled by setting
4118-
<envar>PAGER</envar> to empty, or by using pager-related options of
4119-
the <command>\pset</command> command.
4120-
</para>
4121-
</listitem>
4122-
</varlistentry>
4123-
41244109
<varlistentry>
41254110
<term><envar>PGDATABASE</envar></term>
41264111
<term><envar>PGHOST</envar></term>
@@ -4145,11 +4130,8 @@ $endif
41454130
and <command>\ev</command> commands.
41464131
These variables are examined in the order listed;
41474132
the first that is set is used.
4148-
</para>
4149-
4150-
<para>
4151-
The built-in default editors are <filename>vi</filename> on Unix
4152-
systems and <filename>notepad.exe</filename> on Windows systems.
4133+
If none of them is set, the default is to use <filename>vi</filename>
4134+
on Unix systems or <filename>notepad.exe</filename> on Windows systems.
41534135
</para>
41544136
</listitem>
41554137
</varlistentry>
@@ -4192,6 +4174,27 @@ PSQL_EDITOR_LINENUMBER_ARG='--line '
41924174
</listitem>
41934175
</varlistentry>
41944176

4177+
<varlistentry>
4178+
<term><envar>PSQL_PAGER</envar></term>
4179+
<term><envar>PAGER</envar></term>
4180+
4181+
<listitem>
4182+
<para>
4183+
If a query's results do not fit on the screen, they are piped
4184+
through this command. Typical values are <literal>more</literal>
4185+
or <literal>less</literal>.
4186+
Use of the pager can be disabled by setting <envar>PSQL_PAGER</envar>
4187+
or <envar>PAGER</envar> to an empty string, or by adjusting the
4188+
pager-related options of the <command>\pset</command> command.
4189+
These variables are examined in the order listed;
4190+
the first that is set is used.
4191+
If none of them is set, the default is to use <literal>more</> on most
4192+
platforms, but <literal>less</> on Cygwin.
4193+
</para>
4194+
4195+
</listitem>
4196+
</varlistentry>
4197+
41954198
<varlistentry>
41964199
<term><envar>PSQLRC</envar></term>
41974200

‎src/bin/psql/help.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,6 @@ helpVariables(unsigned short int pager)
459459

460460
fprintf(output,_(" COLUMNS\n"
461461
" number of columns for wrapped format\n"));
462-
fprintf(output,_(" PAGER\n"
463-
" name of external pager program\n"));
464462
fprintf(output,_(" PGAPPNAME\n"
465463
" same as the application_name connection parameter\n"));
466464
fprintf(output,_(" PGDATABASE\n"
@@ -481,6 +479,8 @@ helpVariables(unsigned short int pager)
481479
" how to specify a line number when invoking the editor\n"));
482480
fprintf(output,_(" PSQL_HISTORY\n"
483481
" alternative location for the command history file\n"));
482+
fprintf(output,_(" PSQL_PAGER, PAGER\n"
483+
" name of external pager program\n"));
484484
fprintf(output,_(" PSQLRC\n"
485485
" alternative location for the user's .psqlrc file\n"));
486486
fprintf(output,_(" SHELL\n"

‎src/fe_utils/print.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2870,7 +2870,9 @@ PageOutput(int lines, const printTableOpt *topt)
28702870
constchar*pagerprog;
28712871
FILE*pagerpipe;
28722872

2873-
pagerprog=getenv("PAGER");
2873+
pagerprog=getenv("PSQL_PAGER");
2874+
if (!pagerprog)
2875+
pagerprog=getenv("PAGER");
28742876
if (!pagerprog)
28752877
pagerprog=DEFAULT_PAGER;
28762878
else

‎src/interfaces/libpq/fe-print.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,13 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
165165
screen_size.ws_row=24;
166166
screen_size.ws_col=80;
167167
#endif
168+
169+
/*
170+
* Since this function is no longer used by psql, we don't examine
171+
* PSQL_PAGER. It's possible that the hypothetical external users
172+
* of the function would like that to happen, but in the name of
173+
* backwards compatibility, we'll stick to just examining PAGER.
174+
*/
168175
pagerenv=getenv("PAGER");
169176
/* if PAGER is unset, empty or all-white-space, don't use pager */
170177
if (pagerenv!=NULL&&

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp