aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar BanceDev 2024-09-25 13:58:55 -0400
committerGravatar BanceDev 2024-09-25 13:58:55 -0400
commite067ca5d0b2b6fefe9f2930e7bad6354cd13d172 (patch)
treedbd5dbd2487a02ffb112999927374966bc9dcb84
parentadded || chaining operator (diff)
added ; chaining operator
-rw-r--r--src/lush.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/lush.c b/src/lush.c
index 31a75d7..4c2d17b 100644
--- a/src/lush.c
+++ b/src/lush.c
@@ -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++;
}