summaryrefslogtreecommitdiff
path: root/src/sysctl
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-06-12 15:37:53 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-06-13 14:20:03 +0200
commitdcd5c891cb1627c1e68635cb04beda8a012e0532 (patch)
treeefa61b52e92a60f733891e8fd778b3932c352950 /src/sysctl
parentba1dc1a12b2a114eb66045f472feb6ae544c9684 (diff)
downloadsystemd-dcd5c891cb1627c1e68635cb04beda8a012e0532.tar.gz
binfmt,sysctl,sysuers,tmpfiles: add auto-paging for --cat-config commands
The output of these commands is really long, and already enriched with color. Let's add auto-paging to make this easier to digest.
Diffstat (limited to 'src/sysctl')
-rw-r--r--src/sysctl/sysctl.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c
index 5489cb96b7..a719ea1f9d 100644
--- a/src/sysctl/sysctl.c
+++ b/src/sysctl/sysctl.c
@@ -19,6 +19,7 @@
#include "fileio.h"
#include "hashmap.h"
#include "log.h"
+#include "pager.h"
#include "path-util.h"
#include "string-util.h"
#include "strv.h"
@@ -28,6 +29,7 @@
static char **arg_prefixes = NULL;
static bool arg_cat_config = false;
+static bool arg_no_pager = false;
static int apply_all(OrderedHashmap *sysctl_options) {
char *property, *value;
@@ -170,6 +172,7 @@ static void help(void) {
" --version Show package version\n"
" --cat-config Show configuration files\n"
" --prefix=PATH Only apply rules with the specified prefix\n"
+ " --no-pager Do not pipe output into a pager\n"
, program_invocation_short_name);
}
@@ -179,6 +182,7 @@ static int parse_argv(int argc, char *argv[]) {
ARG_VERSION = 0x100,
ARG_CAT_CONFIG,
ARG_PREFIX,
+ ARG_NO_PAGER,
};
static const struct option options[] = {
@@ -186,6 +190,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "version", no_argument, NULL, ARG_VERSION },
{ "cat-config", no_argument, NULL, ARG_CAT_CONFIG },
{ "prefix", required_argument, NULL, ARG_PREFIX },
+ { "no-pager", no_argument, NULL, ARG_NO_PAGER },
{}
};
@@ -231,6 +236,10 @@ static int parse_argv(int argc, char *argv[]) {
break;
}
+ case ARG_NO_PAGER:
+ arg_no_pager = true;
+ break;
+
case '?':
return -EINVAL;
@@ -287,6 +296,8 @@ int main(int argc, char *argv[]) {
}
if (arg_cat_config) {
+ (void) pager_open(arg_no_pager, false);
+
r = cat_files(NULL, files, 0);
goto finish;
}
@@ -303,6 +314,8 @@ int main(int argc, char *argv[]) {
r = k;
finish:
+ pager_close();
+
ordered_hashmap_free_free_free(sysctl_options);
strv_free(arg_prefixes);