summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/DEVNOTES.md2
-rw-r--r--src/config.h3
-rw-r--r--src/main.c11
-rw-r--r--src/stages.h2
4 files changed, 15 insertions, 3 deletions
diff --git a/docs/DEVNOTES.md b/docs/DEVNOTES.md
index 8093efc..02ba0cc 100644
--- a/docs/DEVNOTES.md
+++ b/docs/DEVNOTES.md
@@ -11,5 +11,7 @@
## LATER
- proper error handling
- marked todos in code
+- extensibility hooks and exposed constant
+- freeing allocs
## BUGS
diff --git a/src/config.h b/src/config.h
new file mode 100644
index 0000000..31e8fa1
--- /dev/null
+++ b/src/config.h
@@ -0,0 +1,3 @@
+#pragma once
+
+static const char* rcfile = "scratch/.yrc";
diff --git a/src/main.c b/src/main.c
index 6653fdd..f595c4a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -9,6 +9,13 @@
#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;
@@ -16,9 +23,7 @@ int main() {
line = readline("$ ");
if (line[0] == '\0') continue;
add_history(line);
- Ast ast = lex(line);
- PipelineTree pltree = process_ast(ast, &shstate);
- execute_pipeline_tree(pltree, &shstate);
+ execute_line(line, &shstate);
}
free(line);
}
diff --git a/src/stages.h b/src/stages.h
index 8c7ed0b..2f90a26 100644
--- a/src/stages.h
+++ b/src/stages.h
@@ -6,3 +6,5 @@
Ast lex(char* input);
PipelineTree process_ast(Ast ast, ShellState* shstate);
void execute_pipeline_tree(PipelineTree pltree, ShellState* shstate);
+//void source_script(char* fname, ShellState* shstate);
+void execute_line(char* line, ShellState* shstate);