blob: 4879e97fcec3bb33c2ded0d4a5e6a2c54f7db438 (
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
30
31
32
33
34
35
|
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <readline/readline.h>
#include <readline/history.h>
#include <string.h>
#include "config.h"
#include "syntax.h"
#include "stages.h"
#include "utils.h"
void execute_string_line(char *line, ShellState *shstate) {
int pgid = -1;
Ast ast = lex(line);
PipelineTree pltree = process_ast(*ast.root, shstate);
execute_command_pipeline(*pltree.root, STDIN_CHA, STDOUT_CHA, true, &pgid, shstate);
}
int main() {
signal(SIGTTIN, SIG_IGN);
signal(SIGTTOU, SIG_IGN);
ShellState shstate = {.shell_vars = make_KeyValMap(256), .aliases = make_KeyValMap(256)};
source_script(RCFILENAME, &shstate);
char* line;
while (1) {
line = readline("$ ");
if (line[0] == '\0') continue;
add_history(line);
execute_string_line(line, &shstate);
}
free(line);
}
|