This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch master in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=a07a608516f2eb7abcf2fdb3922503ea20b3a508 commit a07a608516f2eb7abcf2fdb3922503ea20b3a508 Author: Guillem Jover <guil...@debian.org> AuthorDate: Mon Oct 1 02:58:30 2018 +0200 dpkg, dpkg-query: Add new --no-pager option This makes it possible to disable any pager usage from these programs. For dpkg this also becomes a configuration option. Closes: #909754 --- debian/changelog | 2 ++ man/dpkg-query.man | 3 +++ man/dpkg.man | 3 +++ src/main.c | 11 +++++++++++ src/querycmd.c | 7 +++++++ 5 files changed, 26 insertions(+) diff --git a/debian/changelog b/debian/changelog index 6a958a519..16a80c9e1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -14,6 +14,8 @@ dpkg (1.19.2) UNRELEASED; urgency=medium errors when writing to stdout, otherwise if we quit the pager early, the program will exit with an error code. * libdpkg: Set stdout to be fully buffered when using a pager. + * dpkg, dpkg-query: Add new --no-pager option. For dpkg this is also a + configuration option. Closes: #909754 * Perl modules: - Dpkg::OpenPGP: Ignore Version field in enarmored output. Fixes CPAN#127217. diff --git a/man/dpkg-query.man b/man/dpkg-query.man index bcd477cd0..484395a22 100644 --- a/man/dpkg-query.man +++ b/man/dpkg-query.man @@ -181,6 +181,9 @@ Also load the available file when using the \fB\-\-show\fP and \fB\-\-list\fP commands, which now default to only querying the status file (since dpkg 1.16.2). .TP +.B \-\-no\-pager +Disables the use of any pager when showing information (since dpkg 1.19.2). +.TP .BR \-f ", " \-\-showformat=\fIformat\fR This option is used to specify the format of the output \fB\-\-show\fP will produce. The format is a string that will be output for each package diff --git a/man/dpkg.man b/man/dpkg.man index dd414b816..62ffceda3 100644 --- a/man/dpkg.man +++ b/man/dpkg.man @@ -834,6 +834,9 @@ For conffile changes where \fIdecision\fP is either \fBinstall\fP or \fBkeep\fP. .RE .TP +.B \-\-no\-pager +Disables the use of any pager when showing information (since dpkg 1.19.2). +.TP \fB\-\-no\-debsig\fP Do not try to verify package signatures. .TP diff --git a/src/main.c b/src/main.c index adaff0326..df03d2371 100644 --- a/src/main.c +++ b/src/main.c @@ -48,6 +48,7 @@ #include <dpkg/arch.h> #include <dpkg/subproc.h> #include <dpkg/command.h> +#include <dpkg/pager.h> #include <dpkg/options.h> #include <dpkg/db-fsys.h> @@ -341,6 +342,15 @@ set_debug(const struct cmdinfo *cpi, const char *value) } static void +set_no_pager(const struct cmdinfo *ci, const char *value) +{ + pager_enable(false); + + /* Let's communicate this to our backends. */ + setenv("DPKG_PAGER", "cat", 1); +} + +static void set_filter(const struct cmdinfo *cip, const char *value) { filter_add(value, cip->arg_int); @@ -726,6 +736,7 @@ static const struct cmdinfo cmdinfos[]= { { "no-act", 0, 0, &f_noact, NULL, NULL, 1 }, { "dry-run", 0, 0, &f_noact, NULL, NULL, 1 }, { "simulate", 0, 0, &f_noact, NULL, NULL, 1 }, + { "no-pager", 0, 0, NULL, NULL, set_no_pager, 0 }, { "no-debsig", 0, 0, &f_nodebsig, NULL, NULL, 1 }, /* Alias ('G') for --refuse. */ { NULL, 'G', 0, &fc_downgrade, NULL, NULL, 0 }, diff --git a/src/querycmd.c b/src/querycmd.c index a62b27655..173c4ad91 100644 --- a/src/querycmd.c +++ b/src/querycmd.c @@ -747,6 +747,12 @@ control_show(const char *const *argv) return 0; } +static void +set_no_pager(const struct cmdinfo *ci, const char *value) +{ + pager_enable(false); +} + static void DPKG_ATTR_NORET printversion(const struct cmdinfo *ci, const char *value) { @@ -831,6 +837,7 @@ static const struct cmdinfo cmdinfos[]= { { "admindir", 0, 1, NULL, &admindir, NULL }, { "load-avail", 0, 0, &opt_loadavail, NULL, NULL, 1 }, { "showformat", 'f', 1, NULL, &showformat, NULL }, + { "no-pager", 0, 0, NULL, NULL, set_no_pager }, { "help", '?', 0, NULL, NULL, usage }, { "version", 0, 0, NULL, NULL, printversion }, { NULL, 0, 0, NULL, NULL, NULL } -- Dpkg.Org's dpkg