diff options
author | jhb <jhb@FreeBSD.org> | 2002-06-03 19:42:49 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2002-06-03 19:42:49 +0000 |
commit | f21ffaa690d0b60996de5e458cfc364638ccc2f2 (patch) | |
tree | 2666843aaf01668fd403104c4844c04ae756219e | |
parent | 35664255192dc45706c519e9230f3bf20367fa3f (diff) | |
download | FreeBSD-src-f21ffaa690d0b60996de5e458cfc364638ccc2f2.zip FreeBSD-src-f21ffaa690d0b60996de5e458cfc364638ccc2f2.tar.gz |
Fix handling of the 'noError' variable. According to the code comments,
one can set the 'noError' variable to ignore any errors that occur for the
next command. However, the code was only unsetting 'noError' when an error
actually occurred, so if you set 'noError', the next command completed ok,
and the command after that failed, the second command's failure would be
ignored. This fixes this by performing the 'noError' check earlier and
then unsetting 'noError' after every command that is run.
Sponsored by: The Weather Channel
-rw-r--r-- | usr.sbin/sade/dispatch.c | 23 | ||||
-rw-r--r-- | usr.sbin/sysinstall/dispatch.c | 23 |
2 files changed, 22 insertions, 24 deletions
diff --git a/usr.sbin/sade/dispatch.c b/usr.sbin/sade/dispatch.c index 2aa3fa9..357cd60 100644 --- a/usr.sbin/sade/dispatch.c +++ b/usr.sbin/sade/dispatch.c @@ -263,6 +263,13 @@ dispatchCommand(char *str) msgNotify("Warning: No such command ``%s''", str); i = DITEM_FAILURE; } + /* + * Allow a user to prefix a command with "noError" to cause + * us to ignore any errors for that one command. + */ + if (i != DITEM_SUCCESS && variable_get(VAR_NO_ERROR)) + i = DITEM_SUCCESS; + variable_unset(VAR_NO_ERROR); } return i; } @@ -320,18 +327,10 @@ dispatch_execute(qelement *head) item = (command_buffer *) head->q_forw; if (DITEM_STATUS(dispatchCommand(item->string)) != DITEM_SUCCESS) { - /* - * Allow a user to prefix a command with "noError" to cause - * us to ignore any errors for that one command. - */ - if (variable_get(VAR_NO_ERROR)) - variable_unset(VAR_NO_ERROR); - else { - msgConfirm("Command `%s' failed - rest of script aborted.\n", - item->string); - result |= DITEM_FAILURE; - break; - } + msgConfirm("Command `%s' failed - rest of script aborted.\n", + item->string); + result |= DITEM_FAILURE; + break; } dispatch_free_command(item); } diff --git a/usr.sbin/sysinstall/dispatch.c b/usr.sbin/sysinstall/dispatch.c index 2aa3fa9..357cd60 100644 --- a/usr.sbin/sysinstall/dispatch.c +++ b/usr.sbin/sysinstall/dispatch.c @@ -263,6 +263,13 @@ dispatchCommand(char *str) msgNotify("Warning: No such command ``%s''", str); i = DITEM_FAILURE; } + /* + * Allow a user to prefix a command with "noError" to cause + * us to ignore any errors for that one command. + */ + if (i != DITEM_SUCCESS && variable_get(VAR_NO_ERROR)) + i = DITEM_SUCCESS; + variable_unset(VAR_NO_ERROR); } return i; } @@ -320,18 +327,10 @@ dispatch_execute(qelement *head) item = (command_buffer *) head->q_forw; if (DITEM_STATUS(dispatchCommand(item->string)) != DITEM_SUCCESS) { - /* - * Allow a user to prefix a command with "noError" to cause - * us to ignore any errors for that one command. - */ - if (variable_get(VAR_NO_ERROR)) - variable_unset(VAR_NO_ERROR); - else { - msgConfirm("Command `%s' failed - rest of script aborted.\n", - item->string); - result |= DITEM_FAILURE; - break; - } + msgConfirm("Command `%s' failed - rest of script aborted.\n", + item->string); + result |= DITEM_FAILURE; + break; } dispatch_free_command(item); } |