diff options
| author | Douglas B. Rumbaugh <doug@douglasrumbaugh.com> | 2025-11-01 15:18:03 -0400 |
|---|---|---|
| committer | Douglas B. Rumbaugh <doug@douglasrumbaugh.com> | 2025-11-01 15:18:03 -0400 |
| commit | f84e64b593c6e6fda9e2a907d25ed99d8742d619 (patch) | |
| tree | b82322106129d3a86b246657886b5d596e2640a7 /src/hush.c | |
| parent | ddcf611815c145b1fadca042e65648a7a81cc497 (diff) | |
| download | hush-f84e64b593c6e6fda9e2a907d25ed99d8742d619.tar.gz | |
Added support for required builtins
Diffstat (limited to 'src/hush.c')
| -rw-r--r-- | src/hush.c | 18 |
1 files changed, 6 insertions, 12 deletions
@@ -15,6 +15,7 @@ #include "lexer.h" #include "command.h" #include "variables.h" +#include "builtin.h" FILE *open_input(int argc, char **argv) { FILE *input_file = (argc > 1) ? fopen(argv[1], "r") : stdin; @@ -37,8 +38,6 @@ static size_t get_command_len(char *cmdstr) { void variable_substitution(command *cmds) { for (command *cmd = cmds; cmd; cmd = cmd->next) { - fprintf(stderr, "Before substitution\n"); - print_commands(stderr, cmd); for (size_t i=0; i < MAX_ARGUMENT_CNT + 1; i++) { if (is_variable(cmd->args[i])) { cmd->args[i] = get_variable(cmd->args[i]); @@ -52,9 +51,6 @@ void variable_substitution(command *cmds) { if (is_variable(cmd->infile)) { cmd->infile = get_variable(cmd->infile); } - - fprintf(stderr, "After substitution\n"); - print_commands(stderr, cmd); } } @@ -94,8 +90,6 @@ int main(int argc, char **argv) { } } - // print_parsed_command(stdout, parsed_cmd); - if (parsed_cmd->type == TKN_VARKEY) { if (!add_variable(parsed_cmd->text, parsed_cmd->next->text)) { fprintf(stderr, "ERROR: Failed to create variable\n"); @@ -113,14 +107,14 @@ int main(int argc, char **argv) { variable_substitution(cmds); for (command *cmd = cmds; cmd; cmd = cmd->next) { - pid_t result = execute_command(cmd); - if (result < 0) { - break; + if (!run_builtin(cmd)) { + pid_t result = execute_command(cmd); + if (result < 0) { + break; + } } } - // print_commands(stdout, cmds); - for (command *cmd = cmds; cmd; cmd = cmd->next) { if (cmd->pid > 0) { waitpid(cmd->pid, NULL, 0); |