Skip to content

Commit

Permalink
added ; chaining operator
Browse files Browse the repository at this point in the history
  • Loading branch information
BanceDev committed Sep 25, 2024
1 parent ccf4047 commit e067ca5
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/lush.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
Expand Down

0 comments on commit e067ca5

Please sign in to comment.