diff options
| author | 2024-09-25 13:58:55 -0400 | |
|---|---|---|
| committer | 2024-09-25 13:58:55 -0400 | |
| commit | e067ca5d0b2b6fefe9f2930e7bad6354cd13d172 (patch) | |
| tree | dbd5dbd2487a02ffb112999927374966bc9dcb84 | |
| parent | added || chaining operator (diff) | |
added ; chaining operator
| -rw-r--r-- | src/lush.c | 28 |
1 files changed, 14 insertions, 14 deletions
@@ -1099,21 +1099,21 @@ int lush_execute_chain(lua_State *L, char ***commands, int num_commands) { for (int i = 0; i < num_actions; i++) { - // Handle && operator - if (last_result != 0 && i > 0) { + // Handle &&, ||, and ; operators + if (i > 0) { commands--; - if (is_operator(commands[0][0]) == OP_AND) { - commands += 3; - continue; - } - commands++; - } - - if (last_result == 0 && i > 0) { - commands--; - if (is_operator(commands[0][0]) == OP_OR) { - commands += 3; - continue; + if (last_result != 0) { + if (is_operator(commands[0][0]) == OP_AND || + is_operator(commands[0][0]) == OP_SEMICOLON) { + commands += 3; + continue; + } + } else if (last_result == 0) { + if (is_operator(commands[0][0]) == OP_OR || + is_operator(commands[0][0]) == OP_SEMICOLON) { + commands += 3; + continue; + } } commands++; } |
