diff options
| author | Michael Brown | 2011-03-28 17:32:30 +0200 |
|---|---|---|
| committer | Michael Brown | 2011-03-28 17:32:30 +0200 |
| commit | 1f4c5f90c3274d4c287d493ed03194a2253d327e (patch) | |
| tree | 3f37c848c1840ed61eba529b812e3fc6172d4322 /src/core | |
| parent | [linux] Avoid unused-but-set variable warning in gcc 4.6 (diff) | |
| download | ipxe-1f4c5f90c3274d4c287d493ed03194a2253d327e.tar.gz ipxe-1f4c5f90c3274d4c287d493ed03194a2253d327e.tar.xz ipxe-1f4c5f90c3274d4c287d493ed03194a2253d327e.zip | |
[cmdline] Allow ";" as an unconditional command separator
It is currently possible to construct a sequence of commands to be
executed regardless of success or failure using "|| &&" as the command
separator. (The "||" captures the failure case, the blank command
converts it to a success case.)
Allow ";" to be used as a more visually appealing (and
space-efficient) alternative.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/exec.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/core/exec.c b/src/core/exec.c index 7ce384437..217ed039e 100644 --- a/src/core/exec.c +++ b/src/core/exec.c @@ -143,6 +143,16 @@ static int process_on_failure ( int rc ) { } /** + * Process next command regardless of status from previous command + * + * @v rc Status of previous command + * @ret process Process next command + */ +static int process_always ( int rc __unused ) { + return 1; +} + +/** * Find command terminator * * @v tokens Token list @@ -166,6 +176,10 @@ static int command_terminator ( char **tokens, /* Short-circuit logical AND */ *process_next = process_on_success; return i; + } else if ( strcmp ( tokens[i], ";" ) == 0 ) { + /* Process next command unconditionally */ + *process_next = process_always; + return i; } } |
