Some cleanups for cd/PWD (#667)

* Some cleanups for cd/PWD

* Some cleanups for cd/PWD
This commit is contained in:
JT
2022-01-05 11:26:01 +11:00
committed by GitHub
parent 4584d69715
commit 41dbc641cc
14 changed files with 104 additions and 49 deletions

View File

@ -235,6 +235,8 @@ impl EngineState {
}
}
// FIXME: permanent state changes like this hopefully in time can be removed
// and be replaced by just passing the cwd in where needed
std::env::set_current_dir(cwd)?;
Ok(())
@ -1009,6 +1011,15 @@ impl<'a> StateWorkingSet<'a> {
last.aliases.insert(name, replacement);
}
pub fn get_cwd(&self) -> String {
let pwd = self
.permanent_state
.env_vars
.get("PWD")
.expect("internal error: can't find PWD");
pwd.as_string().expect("internal error: PWD not a string")
}
pub fn set_variable_type(&mut self, var_id: VarId, ty: Type) {
let num_permanent_vars = self.permanent_state.num_vars();
if var_id < num_permanent_vars {