psql-fix-for-empty-PAGER.patch
text/x-diff
Filename: psql-fix-for-empty-PAGER.patch
Type: text/x-diff
Part: 0
Patch
Format: unified
| File | + | − |
|---|---|---|
| doc/src/sgml/ref/psql-ref.sgml | 0 | 0 |
| src/fe_utils/print.c | 0 | 0 |
| src/interfaces/libpq/fe-print.c | 0 | 0 |
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index 261652a..9915731 100644
*** a/doc/src/sgml/ref/psql-ref.sgml
--- b/doc/src/sgml/ref/psql-ref.sgml
*************** $endif
*** 3801,3808 ****
If the query results do not fit on the screen, they are piped
through this command. Typical values are
<literal>more</literal> or <literal>less</literal>. The default
! is platform-dependent. The use of the pager can be disabled by
! using the <command>\pset</command> command.
</para>
</listitem>
</varlistentry>
--- 3801,3809 ----
If the query results do not fit on the screen, they are piped
through this command. Typical values are
<literal>more</literal> or <literal>less</literal>. The default
! is platform-dependent. Use of the pager can be disabled by setting
! <envar>PAGER</envar> to empty, or by using pager-related options of
! the <command>\pset</command> command.
</para>
</listitem>
</varlistentry>
diff --git a/src/fe_utils/print.c b/src/fe_utils/print.c
index 1ec74f1..5c5d285 100644
*** a/src/fe_utils/print.c
--- b/src/fe_utils/print.c
*************** PageOutput(int lines, const printTableOp
*** 2874,2879 ****
--- 2874,2885 ----
pagerprog = getenv("PAGER");
if (!pagerprog)
pagerprog = DEFAULT_PAGER;
+ else
+ {
+ /* if PAGER is empty or all-white-space, don't use pager */
+ if (strspn(pagerprog, " \t\r\n") == strlen(pagerprog))
+ return stdout;
+ }
disable_sigpipe_trap();
pagerpipe = popen(pagerprog, "w");
if (pagerpipe)
diff --git a/src/interfaces/libpq/fe-print.c b/src/interfaces/libpq/fe-print.c
index c33dc42..e596a51 100644
*** a/src/interfaces/libpq/fe-print.c
--- b/src/interfaces/libpq/fe-print.c
*************** PQprint(FILE *fout, const PGresult *res,
*** 166,173 ****
screen_size.ws_col = 80;
#endif
pagerenv = getenv("PAGER");
if (pagerenv != NULL &&
! pagerenv[0] != '\0' &&
!po->html3 &&
((po->expanded &&
nTups * (nFields + 1) >= screen_size.ws_row) ||
--- 166,174 ----
screen_size.ws_col = 80;
#endif
pagerenv = getenv("PAGER");
+ /* if PAGER is unset, empty or all-white-space, don't use pager */
if (pagerenv != NULL &&
! strspn(pagerenv, " \t\r\n") != strlen(pagerenv) &&
!po->html3 &&
((po->expanded &&
nTups * (nFields + 1) >= screen_size.ws_row) ||