aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lush.c40
1 files changed, 30 insertions, 10 deletions
diff --git a/src/lush.c b/src/lush.c
index 9b43324..1cdb50d 100644
--- a/src/lush.c
+++ b/src/lush.c
@@ -1153,28 +1153,52 @@ int lush_execute_chain(lua_State *L, char ***commands, int num_commands) {
}
int num_actions = (num_commands + 1) / 2;
-
int last_result = 0;
+
for (int i = 0; i < num_actions; i++) {
// Determine the operator type between commands
if (i < num_actions - 1) {
int op_type = is_operator(commands[1][0]);
+
+ // Handle '&&' operator
if (op_type == OP_AND && last_result != 0) {
+ commands += 2;
+ continue;
+ }
+
+ // Handle '|', build pipe array
+ if (op_type == OP_PIPE) {
+ char ***pipe_commands =
+ malloc(sizeof(char **) * (num_actions - i));
+ int pipe_count = 0;
+
+ while (i < num_actions - 1 && op_type == OP_PIPE) {
+ pipe_commands[pipe_count++] = commands[0];
+ commands += 2;
+ i++;
+ if (i < num_actions - 1) {
+ op_type = is_operator(commands[1][0]);
+ } else {
+ break;
+ }
+ }
+
+ pipe_commands[pipe_count++] = commands[0];
+ last_result = lush_execute_pipeline(pipe_commands, pipe_count);
+
+ free(pipe_commands);
+ commands += 2;
continue;
}
}
- // Execute the current command if it's not an operator
if (!is_operator(commands[0][0])) {
last_result = run_command(L, commands);
commands += 2;
}
}
- commands -= num_actions * 2;
- printf("sanity check, commands[0]: %s", commands[0][0]);
-
- return 1;
+ return last_result;
}
int lush_execute_pipeline(char ***commands, int num_commands) {
@@ -1355,10 +1379,6 @@ int main(int argc, char *argv[]) {
exit(1);
}
- for (int i = 0; commands[i] != NULL; i++) {
- printf("Command %d: '%s'\n", i, commands[i]);
- }
-
for (int i = 0; args[i]; i++) {
free(args[i]);
}
s=13&d=retro' width='13' height='13' alt='Gravatar' /> Anselm R.Garbe 2-5/+1 2006-08-09removed control sequences which actually aren't implemented anymore (only the...Gravatar Anselm R.Garbe 1-4/+4 2006-08-08fixes to READMEGravatar Anselm R.Garbe 1-2/+2 2006-08-08default colors are bestGravatar Anselm R.Garbe 1-3/+3 2006-08-08noborderGravatar Anselm R.Garbe 1-2/+2 2006-08-08ditoGravatar Anselm R.Garbe 1-2/+2 2006-08-08using a better colorschemeGravatar Anselm R.Garbe 1-1/+1 2006-08-07removed unnecessary typedefGravatar arg@10ksloc.org 1-1/+0 2006-08-07made dmenu(1) more dwm(1) alikeGravatar arg@10ksloc.org 1-23/+22 2006-08-07font size changed as wellGravatar arg@10ksloc.org 1-1/+1 2006-08-07appliead Sanders manpage/Makefile pacthGravatar arg@10ksloc.org 2-2/+2 2006-08-07fixed dmenu.1 version infoGravatar arg@10ksloc.org 1-1/+1 2006-08-07settle with greyGravatar arg@10ksloc.org 1-2/+2 2006-08-07next version is 0.3Gravatar arg@10ksloc.org 1-1/+1 2006-08-07also made my colors tasting better with my overall colorschemeGravatar arg@10ksloc.org 1-3/+3 2006-08-07next attempt for bright background switchGravatar arg@10ksloc.org 1-3/+3 2006-08-07Added tag 0.2 for changeset 656be0f47df545dfdd2e1e0663663b8b1b26f031Gravatar arg@10ksloc.org 1-0/+1 2006-08-07added stripping to dmenu targetGravatar arg@10ksloc.org 1-0/+1 2006-08-07fixed a bad mistake setting the dmenu border to False;Gravatar arg@10ksloc.org 1-1/+0 2006-08-07renamed some functions to make it more readableGravatar arg@10ksloc.org 1-9/+9 2006-08-07updated man pageGravatar arg@10ksloc.org 1-1/+1 2006-08-07updated man pageGravatar arg@10ksloc.org 1-0/+4 2006-08-07removed -t title crap from dmenuGravatar arg@10ksloc.org 2-57/+12 2006-08-05menu now also uses -OsGravatar arg@10ksloc.org 1-2/+2 2006-08-05small changeGravatar arg@10ksloc.org 1-1/+1 2006-08-04yet another fixGravatar arg@10ksloc.org 1-2/+2 2006-08-04fixed README of dmenuGravatar arg@10ksloc.org 1-27/+10 2006-08-04fixed dist targetGravatar arg@10ksloc.org 1-1/+1 2006-08-04removed config.hGravatar arg@10ksloc.org 1-9/+0