diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-11-11 12:56:29 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-11-14 16:25:11 +0100 |
commit | 0221d68a1317407960ea6f88bd4ebc1781999332 (patch) | |
tree | aa6f7d5c2280c44df790b7c042756c8302a4e788 | |
parent | 8e143a123276a9636987b08f555603927ca9e186 (diff) | |
download | systemd-0221d68a1317407960ea6f88bd4ebc1781999332.tar.gz |
basic/pager: convert the pager options to a flags argument
Pretty much everything uses just the first argument, and this doesn't make this
common pattern more complicated, but makes it simpler to pass multiple options.
-rw-r--r-- | src/analyze/analyze.c | 16 | ||||
-rw-r--r-- | src/basic/pager.c | 6 | ||||
-rw-r--r-- | src/basic/pager.h | 7 | ||||
-rw-r--r-- | src/binfmt/binfmt.c | 6 | ||||
-rw-r--r-- | src/boot/bootctl.c | 8 | ||||
-rw-r--r-- | src/busctl/busctl.c | 22 | ||||
-rw-r--r-- | src/cgls/cgls.c | 6 | ||||
-rw-r--r-- | src/core/main.c | 6 | ||||
-rw-r--r-- | src/coredump/coredumpctl.c | 6 | ||||
-rw-r--r-- | src/delta/delta.c | 6 | ||||
-rw-r--r-- | src/journal/journalctl.c | 15 | ||||
-rw-r--r-- | src/locale/localectl.c | 10 | ||||
-rw-r--r-- | src/login/inhibit.c | 6 | ||||
-rw-r--r-- | src/login/loginctl.c | 18 | ||||
-rw-r--r-- | src/machine/machinectl.c | 16 | ||||
-rw-r--r-- | src/mount/mount-tool.c | 6 | ||||
-rw-r--r-- | src/network/networkctl.c | 10 | ||||
-rw-r--r-- | src/nspawn/nspawn.c | 2 | ||||
-rw-r--r-- | src/portable/portablectl.c | 8 | ||||
-rw-r--r-- | src/resolve/resolvectl.c | 10 | ||||
-rw-r--r-- | src/sysctl/sysctl.c | 6 | ||||
-rw-r--r-- | src/systemctl/systemctl.c | 35 | ||||
-rw-r--r-- | src/sysusers/sysusers.c | 6 | ||||
-rw-r--r-- | src/timedate/timedatectl.c | 6 | ||||
-rw-r--r-- | src/tmpfiles/tmpfiles.c | 6 |
25 files changed, 127 insertions, 122 deletions
diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c index d381740dfb..2f889ba17e 100644 --- a/src/analyze/analyze.c +++ b/src/analyze/analyze.c @@ -66,7 +66,7 @@ static enum dot { static char** arg_dot_from_patterns = NULL; static char** arg_dot_to_patterns = NULL; static usec_t arg_fuzz = 0; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static BusTransport arg_transport = BUS_TRANSPORT_LOCAL; static const char *arg_host = NULL; static UnitFileScope arg_scope = UNIT_FILE_SYSTEM; @@ -1023,7 +1023,7 @@ static int analyze_critical_chain(int argc, char *argv[], void *userdata) { } unit_times_hashmap = h; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); puts("The time after the unit is active or started is printed after the \"@\" character.\n" "The time the unit takes to start is printed after the \"+\" character.\n"); @@ -1055,7 +1055,7 @@ static int analyze_blame(int argc, char *argv[], void *userdata) { typesafe_qsort(times, n, compare_unit_time); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); for (u = times; u->has_data; u++) { char ts[FORMAT_TIMESPAN_MAX]; @@ -1303,7 +1303,7 @@ static int dump(int argc, char *argv[], void *userdata) { if (r < 0) return log_error_errno(r, "Failed to create bus connection: %m"); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); if (!sd_bus_can_send(bus, SD_BUS_TYPE_UNIX_FD)) return dump_fallback(bus); @@ -1337,7 +1337,7 @@ static int cat_config(int argc, char *argv[], void *userdata) { char **arg; int r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); STRV_FOREACH(arg, argv + 1) { const char *t = NULL; @@ -1509,7 +1509,7 @@ static void dump_syscall_filter(const SyscallFilterSet *set) { static int dump_syscall_filters(int argc, char *argv[], void *userdata) { bool first = true; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); if (strv_isempty(strv_skip(argv, 1))) { int i; @@ -1696,7 +1696,7 @@ static int help(int argc, char *argv[], void *userdata) { _cleanup_free_ char *link = NULL; int r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = terminal_urlify_man("systemd-analyze", "1", &link); if (r < 0) @@ -1841,7 +1841,7 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case 'H': diff --git a/src/basic/pager.c b/src/basic/pager.c index 7d698666e9..0c17ed5d98 100644 --- a/src/basic/pager.c +++ b/src/basic/pager.c @@ -41,13 +41,13 @@ _noreturn_ static void pager_fallback(void) { _exit(EXIT_SUCCESS); } -int pager_open(bool no_pager, bool jump_to_end) { +int pager_open(PagerFlags flags) { _cleanup_close_pair_ int fd[2] = { -1, -1 }; _cleanup_strv_free_ char **pager_args = NULL; const char *pager; int r; - if (no_pager) + if (flags & PAGER_DISABLE) return 0; if (pager_pid > 0) @@ -96,7 +96,7 @@ int pager_open(bool no_pager, bool jump_to_end) { less_opts = getenv("SYSTEMD_LESS"); if (!less_opts) less_opts = "FRSXMK"; - if (jump_to_end) + if (flags & PAGER_JUMP_TO_END) less_opts = strjoina(less_opts, " +G"); if (setenv("LESS", less_opts, 1) < 0) _exit(EXIT_FAILURE); diff --git a/src/basic/pager.h b/src/basic/pager.h index e0fd34af97..8299e23856 100644 --- a/src/basic/pager.h +++ b/src/basic/pager.h @@ -5,7 +5,12 @@ #include "macro.h" -int pager_open(bool no_pager, bool jump_to_end); +typedef enum PagerFlags { + PAGER_DISABLE = 1 << 0, + PAGER_JUMP_TO_END = 1 << 1, +} PagerFlags; + +int pager_open(PagerFlags flags); void pager_close(void); bool pager_have(void) _pure_; diff --git a/src/binfmt/binfmt.c b/src/binfmt/binfmt.c index 0dd202d086..9cead4a87c 100644 --- a/src/binfmt/binfmt.c +++ b/src/binfmt/binfmt.c @@ -22,7 +22,7 @@ #include "util.h" static bool arg_cat_config = false; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static int delete_rule(const char *rule) { _cleanup_free_ char *x = NULL, *fn = NULL; @@ -160,7 +160,7 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case '?': @@ -212,7 +212,7 @@ int main(int argc, char *argv[]) { } if (arg_cat_config) { - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = cat_files(NULL, files, 0); goto finish; diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c index d1aee188eb..7a20965b6a 100644 --- a/src/boot/bootctl.c +++ b/src/boot/bootctl.c @@ -45,7 +45,7 @@ static char *arg_path = NULL; static bool arg_print_path = false; static bool arg_touch_variables = true; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static int acquire_esp( bool unprivileged_mode, @@ -923,7 +923,7 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case '?': @@ -965,7 +965,7 @@ static int verb_status(int argc, char *argv[], void *userdata) { r = 0; /* If we couldn't determine the path, then don't consider that a problem from here on, just show what we * can show */ - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); if (is_efi_boot()) { _cleanup_free_ char *fw_type = NULL, *fw_info = NULL, *loader = NULL, *loader_path = NULL, *stub = NULL; @@ -1054,7 +1054,7 @@ static int verb_list(int argc, char *argv[], void *userdata) { else { size_t n; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); printf("Boot Loader Entries:\n"); diff --git a/src/busctl/busctl.c b/src/busctl/busctl.c index 9c872ff0aa..2c0f48c437 100644 --- a/src/busctl/busctl.c +++ b/src/busctl/busctl.c @@ -33,7 +33,7 @@ static enum { JSON_SHORT, JSON_PRETTY, } arg_json = JSON_OFF; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static bool arg_legend = true; static const char *arg_address = NULL; static bool arg_unique = false; @@ -155,7 +155,7 @@ static int list_bus_names(int argc, char **argv, void *userdata) { if (r < 0) return log_error_errno(r, "Failed to list names: %m"); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); names = hashmap_new(&string_hash_ops); if (!names) @@ -470,7 +470,7 @@ static int tree_one(sd_bus *bus, const char *service, const char *prefix, bool m p = NULL; } - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); l = set_get_strv(done); if (!l) @@ -504,7 +504,7 @@ static int tree(int argc, char **argv, void *userdata) { if (r < 0) return log_error_errno(r, "Failed to get name list: %m"); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); STRV_FOREACH(i, names) { int q; @@ -534,7 +534,7 @@ static int tree(int argc, char **argv, void *userdata) { printf("\n"); if (argv[2]) { - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); printf("Service %s%s%s:\n", ansi_highlight(), *i, ansi_normal()); } @@ -1033,7 +1033,7 @@ static int introspect(int argc, char **argv, void *userdata) { return bus_log_parse_error(r); } - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); name_width = STRLEN("NAME"); type_width = STRLEN("TYPE"); @@ -1967,7 +1967,7 @@ static int call(int argc, char **argv, void *userdata) { _cleanup_(json_variant_unrefp) JsonVariant *v = NULL; if (arg_json != JSON_SHORT) - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = json_transform_message(reply, &v); if (r < 0) @@ -1976,7 +1976,7 @@ static int call(int argc, char **argv, void *userdata) { json_dump_with_flags(v, stdout); } else if (arg_verbose) { - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = bus_message_dump(reply, stdout, 0); if (r < 0) @@ -2028,7 +2028,7 @@ static int get_property(int argc, char **argv, void *userdata) { _cleanup_(json_variant_unrefp) JsonVariant *v = NULL; if (arg_json != JSON_SHORT) - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = json_transform_variant(reply, contents, &v); if (r < 0) @@ -2037,7 +2037,7 @@ static int get_property(int argc, char **argv, void *userdata) { json_dump_with_flags(v, stdout); } else if (arg_verbose) { - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = bus_message_dump(reply, stdout, BUS_MESSAGE_DUMP_SUBTREE_ONLY); if (r < 0) @@ -2240,7 +2240,7 @@ static int parse_argv(int argc, char *argv[]) { return version(); case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case ARG_NO_LEGEND: diff --git a/src/cgls/cgls.c b/src/cgls/cgls.c index 58d72b51a2..476641c481 100644 --- a/src/cgls/cgls.c +++ b/src/cgls/cgls.c @@ -22,7 +22,7 @@ #include "unit-name.h" #include "util.h" -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static bool arg_kernel_threads = false; static bool arg_all = false; @@ -99,7 +99,7 @@ static int parse_argv(int argc, char *argv[]) { return version(); case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case 'a': @@ -170,7 +170,7 @@ int main(int argc, char *argv[]) { if (r <= 0) goto finish; - r = pager_open(arg_no_pager, false); + r = pager_open(arg_pager_flags); if (r > 0 && arg_full < 0) arg_full = true; diff --git a/src/core/main.c b/src/core/main.c index a866160d76..11537c8140 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -98,7 +98,7 @@ static bool arg_crash_reboot = false; static char *arg_confirm_spawn = NULL; static ShowStatus arg_show_status = _SHOW_STATUS_INVALID; static bool arg_switched_root = false; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static bool arg_service_watchdogs = true; static char ***arg_join_controllers = NULL; static ExecOutput arg_default_std_output = EXEC_OUTPUT_JOURNAL; @@ -922,7 +922,7 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case ARG_VERSION: @@ -2448,7 +2448,7 @@ int main(int argc, char *argv[]) { goto finish; if (IN_SET(arg_action, ACTION_TEST, ACTION_HELP, ACTION_DUMP_CONFIGURATION_ITEMS, ACTION_DUMP_BUS_PROPERTIES)) - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); if (arg_action != ACTION_RUN) skip_setup = true; diff --git a/src/coredump/coredumpctl.c b/src/coredump/coredumpctl.c index 49df8656b6..6160b4bf7a 100644 --- a/src/coredump/coredumpctl.c +++ b/src/coredump/coredumpctl.c @@ -43,7 +43,7 @@ static usec_t arg_since = USEC_INFINITY, arg_until = USEC_INFINITY; static const char* arg_field = NULL; static const char *arg_debugger = NULL; static const char *arg_directory = NULL; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static int arg_no_legend = false; static int arg_one = false; static FILE* arg_output = NULL; @@ -211,7 +211,7 @@ static int parse_argv(int argc, char *argv[]) { return version(); case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case ARG_NO_LEGEND: @@ -659,7 +659,7 @@ static int dump_list(int argc, char **argv, void *userdata) { if (r < 0) return r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); /* The coredumps are likely to compressed, and for just * listing them we don't need to decompress them, so let's diff --git a/src/delta/delta.c b/src/delta/delta.c index 0cda1df2a3..399d438667 100644 --- a/src/delta/delta.c +++ b/src/delta/delta.c @@ -52,7 +52,7 @@ static const char have_dropins[] = "systemd/system\0" "systemd/user\0"; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static int arg_diff = -1; static enum { @@ -596,7 +596,7 @@ static int parse_argv(int argc, char *argv[]) { return version(); case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case 't': { @@ -654,7 +654,7 @@ int main(int argc, char *argv[]) { else if (arg_diff) arg_flags |= SHOW_OVERRIDDEN; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); if (optind < argc) { int i; diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index 8c9a6106df..e5a5acde8d 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -104,11 +104,10 @@ enum { static OutputMode arg_output = OUTPUT_SHORT; static bool arg_utc = false; -static bool arg_pager_end = false; static bool arg_follow = false; static bool arg_full = true; static bool arg_all = false; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static int arg_lines = ARG_LINES_DEFAULT; static bool arg_no_tail = false; static bool arg_quiet = false; @@ -298,7 +297,7 @@ static int help(void) { _cleanup_free_ char *link = NULL; int r; - (void) pager_open(arg_no_pager, arg_pager_end); + (void) pager_open(arg_pager_flags); r = terminal_urlify_man("journalctl", "1", &link); if (r < 0) @@ -492,11 +491,11 @@ static int parse_argv(int argc, char *argv[]) { return version(); case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case 'e': - arg_pager_end = true; + arg_pager_flags |= PAGER_JUMP_TO_END; if (arg_lines == ARG_LINES_DEFAULT) arg_lines = 1000; @@ -1326,7 +1325,7 @@ static int list_boots(sd_journal *j) { if (count == 0) return count; - (void) pager_open(arg_no_pager, arg_pager_end); + (void) pager_open(arg_pager_flags); /* numbers are one less, but we need an extra char for the sign */ w = DECIMAL_STR_WIDTH(count - 1) + 1; @@ -2127,7 +2126,7 @@ int main(int argc, char *argv[]) { } else { bool oneline = arg_action == ACTION_LIST_CATALOG; - (void) pager_open(arg_no_pager, arg_pager_end); + (void) pager_open(arg_pager_flags); if (optind < argc) r = catalog_list_items(stdout, database, oneline, argv + optind); @@ -2495,7 +2494,7 @@ int main(int argc, char *argv[]) { need_seek = true; if (!arg_follow) - (void) pager_open(arg_no_pager, arg_pager_end); + (void) pager_open(arg_pager_flags); if (!arg_quiet && (arg_lines != 0 || arg_follow)) { usec_t start, end; diff --git a/src/locale/localectl.c b/src/locale/localectl.c index e2a9415138..44e3f13db8 100644 --- a/src/locale/localectl.c +++ b/src/locale/localectl.c @@ -24,7 +24,7 @@ #include "verbs.h" #include "virt.h" -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static bool arg_ask_password = true; static BusTransport arg_transport = BUS_TRANSPORT_LOCAL; static char *arg_host = NULL; @@ -199,7 +199,7 @@ static int list_locales(int argc, char **argv, void *userdata) { if (r < 0) return log_error_errno(r, "Failed to read list of locales: %m"); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); strv_print(l); return 0; @@ -241,7 +241,7 @@ static int list_vconsole_keymaps(int argc, char **argv, void *userdata) { if (r < 0) return log_error_errno(r, "Failed to read list of keymaps: %m"); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); strv_print(l); @@ -373,7 +373,7 @@ static int list_x11_keymaps(int argc, char **argv, void *userdata) { strv_sort(list); strv_uniq(list); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); strv_print(list); return 0; @@ -461,7 +461,7 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case ARG_NO_ASK_PASSWORD: diff --git a/src/login/inhibit.c b/src/login/inhibit.c index 8fe64b9184..22fee49a2b 100644 --- a/src/login/inhibit.c +++ b/src/login/inhibit.c @@ -26,7 +26,7 @@ static const char* arg_what = "idle:sleep:shutdown"; static const char* arg_who = NULL; static const char* arg_why = "Unknown reason"; static const char* arg_mode = NULL; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static bool arg_legend = true; static enum { @@ -68,7 +68,7 @@ static int print_inhibitors(sd_bus *bus) { _cleanup_(table_unrefp) Table *table = NULL; int r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = sd_bus_call_method( bus, @@ -241,7 +241,7 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case ARG_NO_LEGEND: diff --git a/src/login/loginctl.c b/src/login/loginctl.c index 2a3289951a..d6250253d6 100644 --- a/src/login/loginctl.c +++ b/src/login/loginctl.c @@ -38,7 +38,7 @@ static char **arg_property = NULL; static bool arg_all = false; static bool arg_value = false; static bool arg_full = false; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static bool arg_legend = true; static const char *arg_kill_who = NULL; static int arg_signal = SIGTERM; @@ -122,7 +122,7 @@ static int list_sessions(int argc, char *argv[], void *userdata) { assert(bus); assert(argv); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = sd_bus_call_method( bus, @@ -203,7 +203,7 @@ static int list_users(int argc, char *argv[], void *userdata) { assert(bus); assert(argv); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = sd_bus_call_method( bus, @@ -260,7 +260,7 @@ static int list_seats(int argc, char *argv[], void *userdata) { assert(bus); assert(argv); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = sd_bus_call_method( bus, @@ -836,7 +836,7 @@ static int show_session(int argc, char *argv[], void *userdata) { properties = !strstr(argv[0], "status"); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); if (argc <= 1) { const char *session, *p = "/org/freedesktop/login1/session/self"; @@ -885,7 +885,7 @@ static int show_user(int argc, char *argv[], void *userdata) { properties = !strstr(argv[0], "status"); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); if (argc <= 1) { /* If not argument is specified inspect the manager @@ -943,7 +943,7 @@ static int show_seat(int argc, char *argv[], void *userdata) { properties = !strstr(argv[0], "status"); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); if (argc <= 1) { /* If not argument is specified inspect the manager @@ -1284,7 +1284,7 @@ static int help(int argc, char *argv[], void *userdata) { _cleanup_free_ char *link = NULL; int r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = terminal_urlify_man("loginctl", "1", &link); if (r < 0) @@ -1435,7 +1435,7 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case ARG_NO_LEGEND: diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c index d408d80c14..5dd46fc4a7 100644 --- a/src/machine/machinectl.c +++ b/src/machine/machinectl.c @@ -57,7 +57,7 @@ static char **arg_property = NULL; static bool arg_all = false; static bool arg_value = false; static bool arg_full = false; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static bool arg_legend = true; static const char *arg_kill_who = NULL; static int arg_signal = SIGTERM; @@ -278,7 +278,7 @@ static int list_machines(int argc, char *argv[], void *userdata) { assert(bus); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = sd_bus_call_method(bus, "org.freedesktop.machine1", @@ -358,7 +358,7 @@ static int list_images(int argc, char *argv[], void *userdata) { assert(bus); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = sd_bus_call_method(bus, "org.freedesktop.machine1", @@ -753,7 +753,7 @@ static int show_machine(int argc, char *argv[], void *userdata) { properties = !strstr(argv[0], "status"); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); if (properties && argc <= 1) { @@ -1091,7 +1091,7 @@ static int show_image(int argc, char *argv[], void *userdata) { properties = !strstr(argv[0], "status"); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); if (argc <= 1) { @@ -2396,7 +2396,7 @@ static int list_transfers(int argc, char *argv[], void *userdata) { double progress; int r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = sd_bus_call_method(bus, "org.freedesktop.import1", @@ -2612,7 +2612,7 @@ static int help(int argc, char *argv[], void *userdata) { _cleanup_free_ char *link = NULL; int r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = terminal_urlify_man("machinectl", "1", &link); if (r < 0) @@ -2852,7 +2852,7 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case ARG_NO_LEGEND: diff --git a/src/mount/mount-tool.c b/src/mount/mount-tool.c index 988dbc5fbd..62b910b487 100644 --- a/src/mount/mount-tool.c +++ b/src/mount/mount-tool.c @@ -36,7 +36,7 @@ enum { } arg_action = ACTION_DEFAULT; static bool arg_no_block = false; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static bool arg_ask_password = true; static bool arg_quiet = false; static BusTransport arg_transport = BUS_TRANSPORT_LOCAL; @@ -177,7 +177,7 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case ARG_NO_ASK_PASSWORD: @@ -1485,7 +1485,7 @@ static int list_devices(void) { typesafe_qsort(items, n, compare_item); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); fputs(ansi_underline(), stdout); for (c = 0; c < _COLUMN_MAX; c++) { diff --git a/src/network/networkctl.c b/src/network/networkctl.c index c4a8fc8bc4..b557a64e4a 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -34,7 +34,7 @@ #include "util.h" #include "verbs.h" -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static bool arg_legend = true; static bool arg_all = false; @@ -248,7 +248,7 @@ static int list_links(int argc, char *argv[], void *userdata) { if (c < 0) return c; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); if (arg_legend) printf("%3s %-16s %-18s %-11s %-10s\n", @@ -874,7 +874,7 @@ static int link_status(int argc, char *argv[], void *userdata) { _cleanup_free_ LinkInfo *links = NULL; int r, c, i; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = sd_netlink_open(&rtnl); if (r < 0) @@ -970,7 +970,7 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) { if (c < 0) return c; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); if (arg_legend) printf("%-16s %-17s %-16s %-11s %-17s %-16s\n", @@ -1121,7 +1121,7 @@ static int parse_argv(int argc, char *argv[]) { return version(); case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case ARG_NO_LEGEND: diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 9f69ee10a8..a3a41d1ab8 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -207,7 +207,7 @@ static int help(void) { _cleanup_free_ char *link = NULL; int r; - (void) pager_open(false, false); + (void) pager_open(false); r = terminal_urlify_man("systemd-nspawn", "1", &link); if (r < 0) diff --git a/src/portable/portablectl.c b/src/portable/portablectl.c index 21e66def50..ff402151e9 100644 --- a/src/portable/portablectl.c +++ b/src/portable/portablectl.c @@ -25,7 +25,7 @@ #include "terminal-util.h" #include "verbs.h" -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static bool arg_legend = true; static bool arg_ask_password = true; static bool arg_quiet = false; @@ -263,7 +263,7 @@ static int inspect_image(int argc, char *argv[], void *userdata) { if (r < 0) return bus_log_parse_error(r); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); if (arg_cat) { printf("%s-- OS Release: --%s\n", ansi_highlight(), ansi_normal()); @@ -776,7 +776,7 @@ static int help(int argc, char *argv[], void *userdata) { _cleanup_free_ char *link = NULL; int r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = terminal_urlify_man("portablectl", "1", &link); if (r < 0) @@ -866,7 +866,7 @@ static int parse_argv(int argc, char *argv[]) { return version(); case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case ARG_NO_LEGEND: diff --git a/src/resolve/resolvectl.c b/src/resolve/resolvectl.c index 9792750fbf..44fa8ee62c 100644 --- a/src/resolve/resolvectl.c +++ b/src/resolve/resolvectl.c @@ -34,7 +34,7 @@ static uint16_t arg_type = 0; static uint16_t arg_class = 0; static bool arg_legend = true; static uint64_t arg_flags = 0; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; bool arg_ifindex_permissive = false; /* If true, don't generate an error if the specified interface index doesn't exist */ static const char *arg_service_family = NULL; @@ -1438,7 +1438,7 @@ static int status_ifindex(sd_bus *bus, int ifindex, const char *name, StatusMode if (r < 0) return log_error_errno(r, "Failed to get link data for %i: %s", ifindex, bus_error_message(&error, r)); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); if (mode == STATUS_DNS) return status_print_strv_ifindex(ifindex, name, link_info.dns); @@ -1684,7 +1684,7 @@ static int status_global(sd_bus *bus, StatusMode mode, bool *empty_line) { if (r < 0) return log_error_errno(r, "Failed to get global data: %s", bus_error_message(&error, r)); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); if (mode == STATUS_DNS) return status_print_strv_global(global_info.dns); @@ -2657,7 +2657,7 @@ static int compat_parse_argv(int argc, char *argv[]) { break; case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case ARG_SET_DNS: @@ -2917,7 +2917,7 @@ static int native_parse_argv(int argc, char *argv[]) { break; case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case '?': diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c index 945ae3746b..9419f7bd73 100644 --- a/src/sysctl/sysctl.c +++ b/src/sysctl/sysctl.c @@ -24,7 +24,7 @@ static char **arg_prefixes = NULL; static bool arg_cat_config = false; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static int apply_all(OrderedHashmap *sysctl_options) { char *property, *value; @@ -243,7 +243,7 @@ static int parse_argv(int argc, char *argv[]) { } case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case '?': @@ -302,7 +302,7 @@ int main(int argc, char *argv[]) { } if (arg_cat_config) { - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = cat_files(NULL, files, 0); goto finish; diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 9d0c40b93c..a18fb598fd 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -113,7 +113,7 @@ static UnitFileScope arg_scope = UNIT_FILE_SYSTEM; static bool arg_wait = false; static bool arg_no_block = false; static bool arg_no_legend = false; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static bool arg_no_wtmp = false; static bool arg_no_sync = false; static bool arg_no_wall = false; @@ -391,6 +391,7 @@ static int output_units_list(const UnitInfo *unit_infos, unsigned c) { const UnitInfo *u; unsigned n_shown = 0; int job_count = 0; + bool full = arg_full || FLAGS_SET(arg_pager_flags, PAGER_DISABLE); max_id_len = STRLEN("UNIT"); load_len = STRLEN("LOAD"); @@ -476,7 +477,7 @@ static int output_units_list(const UnitInfo *unit_infos, unsigned c) { printf("%-*.*s%s\n", desc_len, - !arg_full && arg_no_pager ? (int) desc_len : -1, + full ? -1 : (int) desc_len, "DESCRIPTION", ansi_normal()); } @@ -534,7 +535,7 @@ static int output_units_list(const UnitInfo *unit_infos, unsigned c) { printf("%-*.*s%s\n", desc_len, - !arg_full && arg_no_pager ? (int) desc_len : -1, + full ? -1 : (int) desc_len, u->description, off_underline); } @@ -749,7 +750,7 @@ static int list_units(int argc, char *argv[], void *userdata) { if (r < 0) return r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = get_unit_list_recursive(bus, strv_skip(argv, 1), &unit_infos, &replies, &machines); if (r < 0) @@ -961,7 +962,7 @@ static int list_sockets(int argc, char *argv[], void *userdata) { if (r < 0) return r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); n = get_unit_list_recursive(bus, strv_skip(argv, 1), &unit_infos, &replies, &machines); if (n < 0) @@ -1266,7 +1267,7 @@ static int list_timers(int argc, char *argv[], void *userdata) { if (r < 0) return r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); n = get_unit_list_recursive(bus, strv_skip(argv, 1), &unit_infos, &replies, &machines); if (n < 0) @@ -1551,7 +1552,7 @@ static int list_unit_files(int argc, char *argv[], void *userdata) { return bus_log_parse_error(r); } - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); typesafe_qsort(units, c, compare_unit_file_list); output_unit_file_list(units, c); @@ -1785,7 +1786,7 @@ static int list_dependencies(int argc, char *argv[], void *userdata) { if (r < 0) return r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); puts(u); @@ -2025,7 +2026,7 @@ static int list_machines(int argc, char *argv[], void *userdata) { if (r < 0) return r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); typesafe_qsort(machine_infos, r, compare_machine_info); output_machines_list(machine_infos, r); @@ -2197,7 +2198,7 @@ static void output_jobs_list(sd_bus *bus, const struct job_info* jobs, unsigned return; } - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); id_len = STRLEN("JOB"); unit_len = STRLEN("UNIT"); @@ -2312,7 +2313,7 @@ static int list_jobs(int argc, char *argv[], void *userdata) { if (r < 0) return bus_log_parse_error(r); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); output_jobs_list(bus, jobs, c, skipped); return 0; @@ -5150,7 +5151,7 @@ static int show_all( if (r < 0) return r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); c = (unsigned) r; @@ -5262,7 +5263,7 @@ static int show(int argc, char *argv[], void *userdata) { if (r < 0) return r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); /* If no argument is specified inspect the manager itself */ if (show_mode == SYSTEMCTL_SHOW_PROPERTIES && argc <= 1) @@ -5367,7 +5368,7 @@ static int cat(int argc, char *argv[], void *userdata) { if (r < 0) return log_error_errno(r, "Failed to expand names: %m"); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); STRV_FOREACH(name, names) { _cleanup_free_ char *fragment_path = NULL; @@ -5644,7 +5645,7 @@ static int show_environment(int argc, char *argv[], void *userdata) { if (r < 0) return r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = sd_bus_get_property( bus, @@ -7095,7 +7096,7 @@ static int systemctl_help(void) { _cleanup_free_ char *link = NULL; int r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = terminal_urlify_man("systemctl", "1", &link); if (r < 0) @@ -7656,7 +7657,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) { break; case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case ARG_NO_WALL: diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c index 0c9902adf6..e23360d437 100644 --- a/src/sysusers/sysusers.c +++ b/src/sysusers/sysusers.c @@ -62,7 +62,7 @@ static char *arg_root = NULL; static bool arg_cat_config = false; static const char *arg_replace = NULL; static bool arg_inline = false; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static OrderedHashmap *users = NULL, *groups = NULL; static OrderedHashmap *todo_uids = NULL, *todo_gids = NULL; @@ -1760,7 +1760,7 @@ static int cat_config(void) { if (r < 0) return r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); return cat_files(NULL, files, 0); } @@ -1852,7 +1852,7 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case '?': diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c index 156a6aae6a..d148b45b38 100644 --- a/src/timedate/timedatectl.c +++ b/src/timedate/timedatectl.c @@ -21,7 +21,7 @@ #include "util.h" #include "verbs.h" -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static bool arg_ask_password = true; static BusTransport arg_transport = BUS_TRANSPORT_LOCAL; static char *arg_host = NULL; @@ -288,7 +288,7 @@ static int list_timezones(int argc, char **argv, void *userdata) { if (r < 0) return log_error_errno(r, "Failed to read list of time zones: %m"); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); strv_print(zones); return 0; @@ -791,7 +791,7 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case ARG_MONITOR: diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 7819d96c67..a81cecd2f9 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -153,7 +153,7 @@ static bool arg_create = false; static bool arg_clean = false; static bool arg_remove = false; static bool arg_boot = false; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static char **arg_include_prefixes = NULL; static char **arg_exclude_prefixes = NULL; @@ -2949,7 +2949,7 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case '?': @@ -3147,7 +3147,7 @@ int main(int argc, char *argv[]) { } if (arg_cat_config) { - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = cat_config(config_dirs, argv + optind); goto finish; |