From 827458b06f6543677547f8c3544513c089cf70da Mon Sep 17 00:00:00 2001 From: Aidan Hahn Date: Mon, 8 Nov 2021 00:59:14 -0800 Subject: [PATCH] fix docs, and init stdlib when configuring --- CONFIGURING.md | 2 +- Readme.md | 2 +- src/bin/main.rs | 8 +++++--- src/config.rs | 11 +++++++++-- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/CONFIGURING.md b/CONFIGURING.md index 5db1932..7496a85 100644 --- a/CONFIGURING.md +++ b/CONFIGURING.md @@ -15,7 +15,7 @@ The following are important variables that will determine the runtime behavior o | Variable | Default Value | Explanation | |-|-|-| -| CFG_RELISH_POSIX | 1 | When on, enables POSIX style job control. [more information.](shell.md) | +| CFG_RELISH_POSIX | 0 | When on, enables POSIX style job control. [more information.](shell.md) | | CFG_RELISH_ENV | 1 | When on, variables defined will be synchronized with environment variables. | | CFG_RELISH_PROMPT | (echo "λ ") | *note: this is a function not a variable*. This function will be called to output the prompt each time the REPL loops. | diff --git a/Readme.md b/Readme.md index c6a8af5..768e5c1 100644 --- a/Readme.md +++ b/Readme.md @@ -17,7 +17,7 @@ Relish is a language meant to iterate on the ideas and designs that were tested - TESTS TESTS TESTS ## Configuration -[See docs here](CONFIGURATION.md) +[See docs here](CONFIGURING.md) ## Compilation `$ cargo build` diff --git a/src/bin/main.rs b/src/bin/main.rs index ff0ccef..d2a5faa 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -28,14 +28,16 @@ use relish::stdlib::{get_stdlib}; fn main() { let mut rl = Editor::<()>::new(); - const HIST_FILE: &str = ".relish_hist"; - const CONFIG_FILE_DEFAULT: &str = ".relishrc"; + const HIST_FILE: &str = "/.relish_hist"; + const CONFIG_FILE_DEFAULT: &str = "/.relishrc"; let mut hist: String = "".to_owned(); + let mut cfg: String = "".to_owned(); if let Some(home) = home_dir() { if let Some(h) = home.to_str() { hist = h.to_owned() + HIST_FILE; + cfg = h.to_owned() + CONFIG_FILE_DEFAULT; } } @@ -50,7 +52,7 @@ fn main() { match env::var("RELISH_CFG_FILE") { Ok(s) => configure(s, vt.clone(), ft.clone()), - Err(_) => configure(String::from(CONFIG_FILE_DEFAULT), vt.clone(), ft.clone()) + Err(_) => configure(cfg, vt.clone(), ft.clone()) } match get_stdlib(vt.clone()) { diff --git a/src/config.rs b/src/config.rs index 1137e4e..ec066de 100644 --- a/src/config.rs +++ b/src/config.rs @@ -20,13 +20,20 @@ use crate::func::{FTable, Args, Function, Operation, func_declare}; use crate::segment::{Ast, Ctr}; use crate::lex::lex; use crate::eval::eval; +use crate::stl::get_stdlib; use std::rc::Rc; use std::cell::RefCell; use std::fs; -pub fn configure(filename: String, vars: Rc>, funcs: Rc>) { - define(vars.clone(), String::from("CFG_RELISH_POSIX"), Rc::new(Ctr::String(String::from("1")))); +pub fn configure(filename: String, vars: Rc>, mut funcs: Rc>) { + define(vars.clone(), String::from("CFG_RELISH_POSIX"), Rc::new(Ctr::String(String::from("0")))); define(vars.clone(), String::from("CFG_RELISH_ENV"), Rc::new(Ctr::String(String::from("1")))); + + match get_stdlib(vars.clone()) { + Ok(f) => funcs = f, + Err(s) => println!("{}", s) + } + func_declare(funcs.clone(), Rc::new(RefCell::new(Function{ name: String::from("CFG_RELISH_PROMPT"), loose_syms: false,