summaryrefslogtreecommitdiff
path: root/src/main.c
blob: f595c4a18b9e109fb3d933e2463d32adc7b7f205 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <stdlib.h>
#include <stdio.h>
#include <readline/readline.h>
#include <readline/history.h>
#include <string.h>

#include "syntax.h"
#include "stages.h"
#include "utils.h"


void execute_line(char *line, ShellState *shstate) {
    Ast ast = lex(line);
    PipelineTree pltree = process_ast(ast, shstate);
    execute_pipeline_tree(pltree, shstate);
}


int main() {
    ShellState shstate = {.shell_vars = make_KeyValMap(256), .aliases = make_KeyValMap(256)};
    char* line;
    while (1) {
        line = readline("$ ");
        if (line[0] == '\0') continue;  
        add_history(line);
        execute_line(line, &shstate);
    }
    free(line);
}