core: add 'i' in confirm spawn to give a short summary of the unit to spawn
This commit is contained in:
parent
d172b175f6
commit
eedf223a30
1
NEWS
1
NEWS
|
@ -7,6 +7,7 @@ CHANGES WITH 233 in spe
|
||||||
|
|
||||||
(f)ail, don't execute the command and pretend it failed
|
(f)ail, don't execute the command and pretend it failed
|
||||||
(h)elp
|
(h)elp
|
||||||
|
(i)nfo, show a short summary of the unit
|
||||||
(s)kip, don't execute the command and pretend it succeeded
|
(s)kip, don't execute the command and pretend it succeeded
|
||||||
(y)es, execute the command
|
(y)es, execute the command
|
||||||
|
|
||||||
|
|
|
@ -720,7 +720,7 @@ enum {
|
||||||
CONFIRM_EXECUTE = 1,
|
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;
|
int saved_stdout = -1, saved_stdin = -1, r;
|
||||||
_cleanup_free_ char *e = NULL;
|
_cleanup_free_ char *e = NULL;
|
||||||
char c;
|
char c;
|
||||||
|
@ -740,7 +740,7 @@ static int ask_for_confirmation(const char *vc, const char *cmdline) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (;;) {
|
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) {
|
if (r < 0) {
|
||||||
write_confirm_error_fd(r, STDOUT_FILENO);
|
write_confirm_error_fd(r, STDOUT_FILENO);
|
||||||
r = CONFIRM_EXECUTE;
|
r = CONFIRM_EXECUTE;
|
||||||
|
@ -755,9 +755,16 @@ static int ask_for_confirmation(const char *vc, const char *cmdline) {
|
||||||
case 'h':
|
case 'h':
|
||||||
printf(" f - fail, don't execute the command and pretend it failed\n"
|
printf(" f - fail, don't execute the command and pretend it failed\n"
|
||||||
" h - help\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"
|
" s - skip, don't execute the command and pretend it succeeded\n"
|
||||||
" y - yes, execute the command\n");
|
" y - yes, execute the command\n");
|
||||||
continue;
|
continue;
|
||||||
|
case 'i':
|
||||||
|
printf(" Description: %s\n"
|
||||||
|
" Unit: %s\n"
|
||||||
|
" Command: %s\n",
|
||||||
|
u->id, u->description, cmdline);
|
||||||
|
continue; /* ask again */
|
||||||
case 's':
|
case 's':
|
||||||
printf("Skipping execution.\n");
|
printf("Skipping execution.\n");
|
||||||
r = CONFIRM_PRETEND_SUCCESS;
|
r = CONFIRM_PRETEND_SUCCESS;
|
||||||
|
@ -2368,7 +2375,7 @@ static int exec_child(
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = ask_for_confirmation(vc, cmdline);
|
r = ask_for_confirmation(vc, unit, cmdline);
|
||||||
if (r != CONFIRM_EXECUTE) {
|
if (r != CONFIRM_EXECUTE) {
|
||||||
if (r == CONFIRM_PRETEND_SUCCESS) {
|
if (r == CONFIRM_PRETEND_SUCCESS) {
|
||||||
*exit_status = EXIT_SUCCESS;
|
*exit_status = EXIT_SUCCESS;
|
||||||
|
|
Loading…
Reference in a new issue