summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorÁkos Kőrösi <korakos99@gmail.com>2026-05-22 11:20:01 +0200
committerÁkos Kőrösi <korakos99@gmail.com>2026-05-22 11:20:01 +0200
commit3ee20b6b9b0dee56f4ffcb8b80c8b8390589a5f6 (patch)
treef1389dfaa7420a264acf274b90b77f32f406922d /src
parent75c3a166b98aa5c89fa3a8c82c70ef9f9fb54416 (diff)
add rc sourcing
Diffstat (limited to 'src')
-rw-r--r--src/config.h2
-rw-r--r--src/main.c2
-rw-r--r--src/stages.h2
3 files changed, 4 insertions, 2 deletions
diff --git a/src/config.h b/src/config.h
index 31e8fa1..c1c8de2 100644
--- a/src/config.h
+++ b/src/config.h
@@ -1,3 +1,3 @@
#pragma once
-static const char* rcfile = "scratch/.yrc";
+static const char* RCFILENAME= "scratch/.yrc";
diff --git a/src/main.c b/src/main.c
index f595c4a..9e30c27 100644
--- a/src/main.c
+++ b/src/main.c
@@ -4,6 +4,7 @@
#include <readline/history.h>
#include <string.h>
+#include "config.h"
#include "syntax.h"
#include "stages.h"
#include "utils.h"
@@ -18,6 +19,7 @@ void execute_line(char *line, ShellState *shstate) {
int main() {
ShellState shstate = {.shell_vars = make_KeyValMap(256), .aliases = make_KeyValMap(256)};
+ source_script(RCFILENAME, &shstate);
char* line;
while (1) {
line = readline("$ ");
diff --git a/src/stages.h b/src/stages.h
index 2f90a26..e731533 100644
--- a/src/stages.h
+++ b/src/stages.h
@@ -6,5 +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 source_script(char* fname, ShellState* shstate);
void execute_line(char* line, ShellState* shstate);