From eedf223a30cca99b5d82f620437d2366be0eaf30 Mon Sep 17 00:00:00 2001 From: Franck Bui Date: Sat, 12 Nov 2016 14:55:12 +0100 Subject: [PATCH] core: add 'i' in confirm spawn to give a short summary of the unit to spawn --- NEWS | 1 + src/core/execute.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index fde3d6caf6..a145c3ab6e 100644 --- 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 diff --git a/src/core/execute.c b/src/core/execute.c index 65ba9acf7a..b48a5732f3 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -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;