fixed permissions issue in load-with

This commit is contained in:
Ava Apples Affine 2023-03-30 20:02:45 -07:00
parent e8cf59b7a7
commit dcbc855783
Signed by: affine
GPG key ID: 3A4645B8CF806069
3 changed files with 46 additions and 16 deletions

View file

@ -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