diff options
author | Guillem Jover <guillem@debian.org> | 2018-10-01 02:58:30 +0200 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2018-10-08 12:11:52 +0200 |
commit | a07a608516f2eb7abcf2fdb3922503ea20b3a508 (patch) | |
tree | fbb8b989a4ae8f1e8e90261a57ceba8585927e3b /src | |
parent | 68b0f4dd8ac3f541926796a303015df782ef76ed (diff) | |
download | dpkg-a07a608516f2eb7abcf2fdb3922503ea20b3a508.tar.gz |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 11 | ||||
-rw-r--r-- | src/querycmd.c | 7 |
2 files changed, 18 insertions, 0 deletions
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 } |