mirror of https://github.com/ipxe/ipxe.git
[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>pull/1/head
parent
914dc6bfa9
commit
1f4c5f90c3
|
@ -142,6 +142,16 @@ static int process_on_failure ( int rc ) {
|
||||||
return ( rc != 0 );
|
return ( rc != 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
* Find command terminator
|
||||||
*
|
*
|
||||||
|
@ -166,6 +176,10 @@ static int command_terminator ( char **tokens,
|
||||||
/* Short-circuit logical AND */
|
/* Short-circuit logical AND */
|
||||||
*process_next = process_on_success;
|
*process_next = process_on_success;
|
||||||
return i;
|
return i;
|
||||||
|
} else if ( strcmp ( tokens[i], ";" ) == 0 ) {
|
||||||
|
/* Process next command unconditionally */
|
||||||
|
*process_next = process_always;
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue