aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lush.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/lush.c b/src/lush.c
index c3bd831..68447b0 100644
--- a/src/lush.c
+++ b/src/lush.c
@@ -1126,13 +1126,8 @@ int lush_execute_chain(lua_State *L, char ***commands, int num_commands) {
int last_result = 0;
for (int i = 0; i < num_actions; i++) {
- // Handle ; operator
- if (is_operator(commands[0][0]) == OP_SEMICOLON) {
- commands++;
- }
-
- // Handle && and || operators
- if (i > 0) {
+ // Handle &&, ||, and ; operators
+ if (i > 0 && commands[0] != NULL) {
commands--;
if (last_result != 0) {
if (is_operator(commands[0][0]) == OP_AND) {
@@ -1146,6 +1141,10 @@ int lush_execute_chain(lua_State *L, char ***commands, int num_commands) {
}
}
commands++;
+
+ if (is_operator(commands[0][0]) == OP_SEMICOLON) {
+ commands++;
+ }
}
// Handle other operations
@@ -1174,15 +1173,15 @@ int lush_execute_chain(lua_State *L, char ***commands, int num_commands) {
commands += 2;
continue;
} else if (op_type == OP_BACKGROUND) {
- run_command_background(L, commands);
+ last_result = run_command_background(L, commands);
commands += 2;
continue;
} else if (op_type == OP_REDIRECT_OUT) {
- run_command_redirect(L, commands, O_TRUNC);
+ last_result = run_command_redirect(L, commands, O_TRUNC);
commands += 3; // to go past fd given
continue;
} else if (op_type == OP_APPEND_OUT) {
- run_command_redirect(L, commands, O_APPEND);
+ last_result = run_command_redirect(L, commands, O_APPEND);
commands += 3;
continue;
}
/d6b757ad4778d8cac81581905dad5f4e?s=13&d=retro' width='13' height='13' alt='Gravatar' /> BanceDev 1-3/+3 2024-09-12v0.1.1Gravatar BanceDev 1-1/+1 2024-09-12fixed bug in input buffer handling due to misplaced printGravatar BanceDev 2-5/+8 2024-09-12Update build.yml checkout v4Gravatar Lance Borden 1-1/+1 2024-09-12Update build.yml to artifact v4Gravatar Lance Borden 1-1/+1 2024-09-12fixed exit status issue with non interative modeGravatar BanceDev 1-1/+1 2024-09-12added non interative mode for running lua scriptsGravatar BanceDev 2-4/+28 2024-09-12temporary github action fix until non-interactive mode is implementedGravatar BanceDev 1-2/+2 2024-09-12attempt to update build script to accept input into lush shellGravatar BanceDev 2-4/+6 2024-09-12prevent lush workflow from getting stuck in testsGravatar Lance Borden 1-1/+4 2024-09-12removed chsh in workflowGravatar Lance Borden 1-4/+1