aboutsummaryrefslogtreecommitdiffstats
path: root/src/lush.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lush.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/lush.c b/src/lush.c
index 629c4b5..78e7fb7 100644
--- a/src/lush.c
+++ b/src/lush.c
@@ -928,11 +928,14 @@ char **lush_split_commands(char *line) {
int pos = 0;
char *start = line;
+ bool in_quote = false;
while (*start) {
// Skip leading spaces
while (isspace((unsigned char)*start))
start++;
+ // Check if entering or leaving a quoted string
+
// Check for operators
int op_len = operator_length(start);
if (op_len > 0) {
@@ -944,8 +947,14 @@ char **lush_split_commands(char *line) {
} else {
// Collect regular commands until the next operator or end of string
char *next = start;
- while (*next && !is_operator(next)) {
+ while (*next) {
+ if (*next == '"') {
+ in_quote = !in_quote;
+ }
next++;
+
+ if (!in_quote && is_operator(next))
+ break;
}
// Copy the command between start and next
@@ -1213,7 +1222,6 @@ int lush_execute_command(char **args, int input_fd, int output_fd) {
// execute the command
if (execvp(args[0], args) == -1) {
perror("execvp");
- printf("the file: %s\n", args[0]);
exit(EXIT_FAILURE);
}
} else if (pid < 0) {
@@ -1324,9 +1332,6 @@ int main(int argc, char *argv[]) {
}
char *expanded_line = lush_resolve_aliases(line);
char **commands = lush_split_commands(expanded_line);
- for (int i = 0; commands[i] != NULL; i++) {
- printf("Command %d: '%s'\n", i, commands[i]);
- }
char ***args = lush_split_args(commands, &status);
if (status == -1) {
fprintf(stderr, "lush: Expected end of quoted string\n");
e&follow=1'>v0.2.1Gravatar BanceDev 1-1/+1 2024-09-25fixed semicolon chaining functionalityGravatar BanceDev 1-14/+9 2024-09-25v0.2.0Gravatar BanceDev 1-1/+1 2024-09-25fixed crash from incorrect pointer indexingGravatar BanceDev 1-1/+1 2024-09-25added append chaining operatorGravatar BanceDev 1-3/+7 2024-09-25added output redirection withGravatar BanceDev 1-12/+52 2024-09-25added ; chaining operatorGravatar BanceDev 1-14/+14 2024-09-25added || chaining operatorGravatar BanceDev 1-2/+9 2024-09-25Update README.mdGravatar Lance Borden 1-0/+3 2024-09-23fixed lua api exit status issueGravatar BanceDev 1-1/+1 2024-09-23fixed splitting within quoted stringGravatar BanceDev 1-5/+10 2024-09-23made and operator actually conditionalGravatar BanceDev 2-17/+27 2024-09-23fixed operator chaining to handle commands terminating with an operatorGravatar BanceDev 1-14/+5 2024-09-23implemented background process operatorGravatar BanceDev 6-154/+238 2024-09-23implemented piping into new chaining methodGravatar BanceDev 1-10/+30 2024-09-18fixed && chaining for builtinsGravatar BanceDev 2-23/+31 2024-09-18added basic && chainingGravatar BanceDev 2-8/+73 2024-09-17changed tokenizer to handle all the chaining operatorsGravatar BanceDev 3-20/+78 2024-09-17Update README.mdGravatar Lance Borden 1-0/+1 2024-09-13added better clarification to help menuGravatar BanceDev 1-1/+2 2024-09-13improved installation instructionsGravatar 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