]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
run: drop "-" prefix from command line when generating unit description
authorLennart Poettering <lennart@poettering.net>
Thu, 24 Oct 2024 10:14:01 +0000 (12:14 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 25 Oct 2024 15:32:19 +0000 (17:32 +0200)
Let's not confuse users with the login shell indicator and drop it from
the description. This means a run0 session will now usually show up with
a description of "[run0] /bin/bash" rather than "[run0] -/bin/bash".

src/run/run.c

index d4eb148cf64e1fb09270de15ce93601aaf667a71..6b9e19e2d1a031cf909a8a578eb4cfb9d787ec40 100644 (file)
@@ -2439,7 +2439,19 @@ static int run(int argc, char* argv[]) {
 
                 if (strv_isempty(arg_cmdline))
                         t = strdup(arg_unit);
-                else
+                else if (startswith(arg_cmdline[0], "-")) {
+                        /* Drop the login shell marker from the command line when generating the description,
+                         * in order to minimize user confusion. */
+                        _cleanup_strv_free_ char **l = strv_copy(arg_cmdline);
+                        if (!l)
+                                return log_oom();
+
+                        r = free_and_strdup_warn(l + 0, l[0] + 1);
+                        if (r < 0)
+                                return r;
+
+                        t = quote_command_line(l, SHELL_ESCAPE_EMPTY);
+                } else
                         t = quote_command_line(arg_cmdline, SHELL_ESCAPE_EMPTY);
                 if (!t)
                         return log_oom();