]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemd-run: add --no-pager, use pager for --help
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 10 Jul 2025 09:30:01 +0000 (11:30 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 11 Jul 2025 10:01:42 +0000 (19:01 +0900)
man/systemd-run.xml
shell-completion/bash/systemd-run
shell-completion/zsh/_systemd-run
src/run/run.c

index 0ba002b0ebd1e07f261105376ae4f6fd2c0adccb..69edd052f1b180384aa77c7d791b294e81812a0d 100644 (file)
       <xi:include href="standard-options.xml" xpointer="help" />
       <xi:include href="standard-options.xml" xpointer="version" />
       <xi:include href="standard-options.xml" xpointer="json" />
+
+      <varlistentry id='no-pager'>
+        <term><option>--no-pager</option></term>
+
+        <listitem><para>Do not pipe output into a pager. This currently only applies to
+        <option>--help</option>. (The pager is not started during normal operation.)</para>
+
+        <xi:include href="version-info.xml" xpointer="v256"/>
+        </listitem>
+      </varlistentry>
     </variablelist>
 
     <para>All command line arguments after the first non-option argument become part of the command line of
index 60017c1c1c05309db17fe731b1320191a26f8c8f..4374d519a076d6e4756f9da105f083adadfd4194 100644 (file)
@@ -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
index 1e24ff8e9f0a7e6b6ce277e330f1d26c42050274..6d4a3a29aec91877f094307d491d1148a93c95fa 100644 (file)
@@ -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' \
index b87de821374ade9966139948375c743f70059a8a..b7c4facabc7bde6060eb0c9aba23a285f05893c6 100644 (file)
@@ -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)