From: Zbigniew Jędrzejewski-Szmek Date: Thu, 10 Jul 2025 09:30:01 +0000 (+0200) Subject: systemd-run: add --no-pager, use pager for --help X-Git-Tag: v258-rc1~90 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=63770fa1d3eb0c8a367d0ffab73772e3c96a509f;p=thirdparty%2Fsystemd.git systemd-run: add --no-pager, use pager for --help --- diff --git a/man/systemd-run.xml b/man/systemd-run.xml index 0ba002b0ebd..69edd052f1b 100644 --- a/man/systemd-run.xml +++ b/man/systemd-run.xml @@ -565,6 +565,16 @@ + + + + + Do not pipe output into a pager. This currently only applies to + . (The pager is not started during normal operation.) + + + + All command line arguments after the first non-option argument become part of the command line of diff --git a/shell-completion/bash/systemd-run b/shell-completion/bash/systemd-run index 60017c1c1c0..4374d519a07 100644 --- a/shell-completion/bash/systemd-run +++ b/shell-completion/bash/systemd-run @@ -40,7 +40,8 @@ _systemd_run() { --path-property --socket-property --timer-property -H --host -M --machine --expand-environment --background --json --job-mode ) - local OPTS="${opts_with_values[*]} --no-ask-password --scope -u --slice-inherit -r --remain-after-exit + local OPTS="${opts_with_values[*]} --no-ask-password --no-pager + --scope -u --slice-inherit -r --remain-after-exit --send-sighup -d --same-dir -t --pty -P --pipe -S --shell -q --quiet --ignore-failure --on-clock-change --on-timezone-change --no-block --wait -G --collect --user --system -h --help --version -v --verbose" local mode=--system diff --git a/shell-completion/zsh/_systemd-run b/shell-completion/zsh/_systemd-run index 1e24ff8e9f0..6d4a3a29aec 100644 --- a/shell-completion/zsh/_systemd-run +++ b/shell-completion/zsh/_systemd-run @@ -47,6 +47,7 @@ _arguments \ '(-C --capsule)'{-C,--capsule=}'[Operate on capsule]:capsule' \ '--nice=[Nice level]:nice level' \ '--no-ask-password[Do not query the user for authentication]' \ + '--no-pager[Do not spawn a pager]' \ '(--wait)--no-block[Do not synchronously wait for the unit start operation to finish]' \ '--on-active=[Run after SEC seconds]:SEC' \ '--on-boot=[Run SEC seconds after machine was booted up]:SEC' \ diff --git a/src/run/run.c b/src/run/run.c index b87de821374..b7c4facabc7 100644 --- a/src/run/run.c +++ b/src/run/run.c @@ -42,6 +42,7 @@ #include "log.h" #include "main-func.h" #include "osc-context.h" +#include "pager.h" #include "parse-argument.h" #include "parse-util.h" #include "path-util.h" @@ -110,6 +111,7 @@ static char **arg_cmdline = NULL; static char *arg_exec_path = NULL; static bool arg_ignore_failure = false; static char *arg_background = NULL; +static PagerFlags arg_pager_flags = 0; static sd_json_format_flags_t arg_json_format_flags = SD_JSON_FORMAT_OFF; static char *arg_shell_prompt_prefix = NULL; static int arg_lightweight = -1; @@ -133,6 +135,8 @@ static int help(void) { _cleanup_free_ char *link = NULL; int r; + pager_open(arg_pager_flags); + r = terminal_urlify_man("systemd-run", "1", &link); if (r < 0) return log_oom(); @@ -177,6 +181,7 @@ static int help(void) { " when queueing a new job\n" " --ignore-failure Ignore the exit status of the invoked process\n" " --background=COLOR Set ANSI color for background\n" + " --no-pager Do not pipe output into a pager\n" "\n%3$sPath options:%4$s\n" " --path-property=NAME=VALUE Set path unit property\n" "\n%3$sSocket options:%4$s\n" @@ -318,6 +323,7 @@ static int parse_argv(int argc, char *argv[]) { ARG_JOB_MODE, ARG_IGNORE_FAILURE, ARG_BACKGROUND, + ARG_NO_PAGER, ARG_JSON, }; @@ -370,6 +376,7 @@ static int parse_argv(int argc, char *argv[]) { { "job-mode", required_argument, NULL, ARG_JOB_MODE }, { "ignore-failure", no_argument, NULL, ARG_IGNORE_FAILURE }, { "background", required_argument, NULL, ARG_BACKGROUND }, + { "no-pager", no_argument, NULL, ARG_NO_PAGER }, { "json", required_argument, NULL, ARG_JSON }, {}, }; @@ -684,6 +691,10 @@ static int parse_argv(int argc, char *argv[]) { return r; break; + case ARG_NO_PAGER: + arg_pager_flags |= PAGER_DISABLE; + break; + case ARG_JSON: r = parse_json_argument(optarg, &arg_json_format_flags); if (r <= 0)