]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: add 'i' in confirm spawn to give a short summary of the unit to spawn
authorFranck Bui <fbui@suse.com>
Sat, 12 Nov 2016 13:55:12 +0000 (14:55 +0100)
committerFranck Bui <fbui@suse.com>
Thu, 17 Nov 2016 17:16:50 +0000 (18:16 +0100)
NEWS
src/core/execute.c

diff --git a/NEWS b/NEWS
index fde3d6caf6a915d0f36d77351b3c539b11b71a35..a145c3ab6ed8937ee10c7f1bfb28a5107b527a06 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ CHANGES WITH 233 in spe
 
            (f)ail, don't execute the command and pretend it failed
            (h)elp
+           (i)nfo, show a short summary of the unit
            (s)kip, don't execute the command and pretend it succeeded
            (y)es, execute the command
 
index 65ba9acf7a43f7069ede6bd45617e5e8449b91ff..b48a5732f3cdcc420da5c305ea18505606b74be9 100644 (file)
@@ -720,7 +720,7 @@ enum {
         CONFIRM_EXECUTE = 1,
 };
 
-static int ask_for_confirmation(const char *vc, const char *cmdline) {
+static int ask_for_confirmation(const char *vc, Unit *u, const char *cmdline) {
         int saved_stdout = -1, saved_stdin = -1, r;
         _cleanup_free_ char *e = NULL;
         char c;
@@ -740,7 +740,7 @@ static int ask_for_confirmation(const char *vc, const char *cmdline) {
         }
 
         for (;;) {
-                r = ask_char(&c, "yfsh", "Execute %s? [y, f, s – h for help] ", e);
+                r = ask_char(&c, "yfshi", "Execute %s? [y, f, s – h for help] ", e);
                 if (r < 0) {
                         write_confirm_error_fd(r, STDOUT_FILENO);
                         r = CONFIRM_EXECUTE;
@@ -755,9 +755,16 @@ static int ask_for_confirmation(const char *vc, const char *cmdline) {
                 case 'h':
                         printf("  f - fail, don't execute the command and pretend it failed\n"
                                "  h - help\n"
+                               "  i - info, show a short summary of the unit\n"
                                "  s - skip, don't execute the command and pretend it succeeded\n"
                                "  y - yes, execute the command\n");
                         continue;
+                case 'i':
+                        printf("  Description: %s\n"
+                               "  Unit:        %s\n"
+                               "  Command:     %s\n",
+                               u->id, u->description, cmdline);
+                        continue; /* ask again */
                 case 's':
                         printf("Skipping execution.\n");
                         r = CONFIRM_PRETEND_SUCCESS;
@@ -2368,7 +2375,7 @@ static int exec_child(
                         return -ENOMEM;
                 }
 
-                r = ask_for_confirmation(vc, cmdline);
+                r = ask_for_confirmation(vc, unit, cmdline);
                 if (r != CONFIRM_EXECUTE) {
                         if (r == CONFIRM_PRETEND_SUCCESS) {
                                 *exit_status = EXIT_SUCCESS;