mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 13:26:01 +02:00
Some cleanups for cd/PWD (#667)
* Some cleanups for cd/PWD * Some cleanups for cd/PWD
This commit is contained in:
@ -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 {
|
||||
|
Reference in New Issue
Block a user