summaryrefslogtreecommitdiff
path: root/src/main.c
blob: 1f9198b5d21eb8ffa3d278f7ce1cefaf24ef5519 (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
#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"


int main() {
    ShellState shstate = {.shell_vars = make_KeyValMap(256), .aliases = make_KeyValMap(256)};
    char* line;
    while (1) {
        line = readline("$ ");
        if (line[0] == '\0') continue;  
        if (strcmp(line, "exit") == 0) exit(0);
        add_history(line);
        Ast ast = lex(line);
        PipelineTree pltree = process_ast(ast, &shstate);
        execute_pipeline_tree(pltree);
    }
    free(line);
}