From dcbc85578388e820c1c12e2d2d93d3d4c75b336c Mon Sep 17 00:00:00 2001 From: Ava Hahn Date: Thu, 30 Mar 2023 20:02:45 -0700 Subject: [PATCH] fixed permissions issue in load-with --- Cargo.toml | 50 ++++++++++++++++++++++++++++++++++-------------- Readme.org | 1 + src/stl/posix.rs | 11 +++++++++-- 3 files changed, 46 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c5de0f2..d456d25 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,14 +1,36 @@ -[package] -name = "relish" -version = "0.1.0" -authors = ["Ava "] -edition = "2018" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -dirs = "3.0" -nu-ansi-term = "0.47.0" -reedline = "0.17.0" -nix = "0.26.2" -ctrlc = { version = "3.0", features = ["termination"] } \ No newline at end of file +Readme.org:65:Function calls are executed as soon as the tree is evaluated. See the following example: +Readme.org:324:You can use it by calling it in your shell config (See file:snippets/basic_minimal_configuration.rls for more info). +Readme.org:382:See file:snippets/basic_minimal_configuration.rls for an example of a basic minimal configuration file. +snippets/userlib.rls:13:;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +snippets/userlib.rls:45: See the userlib tests for an easy to follow example of this.' +snippets/userlib-tests.rls:13:;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +snippets/legacy/eval_draft2.rs:11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +snippets/legacy/initial_rough_spaghetti_implementation/eval.rs:11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +snippets/legacy/initial_rough_spaghetti_implementation/bin/main.rs:11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +snippets/legacy/initial_rough_spaghetti_implementation/func.rs:11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +snippets/legacy/initial_rough_spaghetti_implementation/segment.rs:11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +snippets/legacy/initial_rough_spaghetti_implementation/control.rs:11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +snippets/legacy/initial_rough_spaghetti_implementation/stl.rs:11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +snippets/legacy/initial_rough_spaghetti_implementation/str.rs:11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +snippets/legacy/initial_rough_spaghetti_implementation/config.rs:11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +snippets/legacy/initial_rough_spaghetti_implementation/lib.rs:11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +snippets/legacy/initial_rough_spaghetti_implementation/lex.rs:11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +snippets/legacy/initial_rough_spaghetti_implementation/append.rs:11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +snippets/legacy/initial_rough_spaghetti_implementation/vars.rs:11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +snippets/legacy/seperate_tables/func.rs:11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +snippets/legacy/seperate_tables/vars.rs:11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +src/eval.rs:11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +src/bin/main.rs:11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +src/run.rs:11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +src/segment.rs:11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +src/sym.rs:11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +src/stl.rs:11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +src/stl/posix.rs:11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +src/stl/decl.rs:11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +src/stl/strings.rs:11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +src/stl/control.rs:11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +src/stl/math.rs:10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +src/stl/boolean.rs:10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +src/stl/append.rs:10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +src/lib.rs:11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +src/lex.rs:11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the diff --git a/Readme.org b/Readme.org index 9df6fed..5c56b36 100644 --- a/Readme.org +++ b/Readme.org @@ -495,6 +495,7 @@ Note: this section only tracks the state of incomplete TODO items. Having everyt - pwd - Documentation! - Do I need some linemode management stuff? + - Fake load in pre-posix shell outputs "shell not yet configured!" - Escape sequences in strings - logging library - make const all the error messages diff --git a/src/stl/posix.rs b/src/stl/posix.rs index 4aac90b..4f0bc46 100644 --- a/src/stl/posix.rs +++ b/src/stl/posix.rs @@ -26,6 +26,7 @@ use std::fs::File; use std::process::{Command, Child, Stdio}; use nix::unistd; use ctrlc; +use std::fs::OpenOptions; pub struct ShellState { pub parent_pid: unistd::Pid, @@ -201,7 +202,10 @@ fn load_with_callback(ast: &Seg, syms: &mut SymTable, state: &mut ShellState) -> return false } - let out = File::open(filename).or(File::create(filename)); + let out = OpenOptions::new() + .write(true) + .create(true) + .open(filename); if !out.is_ok() { e = Some(out.unwrap_err().to_string()); return false @@ -215,7 +219,10 @@ fn load_with_callback(ast: &Seg, syms: &mut SymTable, state: &mut ShellState) -> return false } - let err = File::open(filename).or(File::create(filename)); + let err = OpenOptions::new() + .write(true) + .create(true) + .open(filename); if !err.is_ok() { e = Some(err.unwrap_err().to_string()); return false