Fix set_pwd() return Result logic.

This commit is contained in:
Zhenping Zhao 2024-12-15 15:33:33 -08:00
parent 569929983c
commit 1057e648b0

View file

@ -81,7 +81,10 @@ pub mod windows {
Ok(path_string) => {
if let Some(drive) = extract_drive_letter(&path_string) {
maintainer.maintain(env_var_for_drive(drive), value.clone());
}
Ok(())
} else if path_string.is_empty() {
Ok(())
} else {
// Other path format, like UNC Network share path, or bash format
// /c/Users/nushell will be supported later.
Err(ShellError::InvalidValue {
@ -90,6 +93,7 @@ pub mod windows {
span: Span::unknown(),
})
}
}
Err(e) => Err(ShellError::InvalidValue {
valid: "$env.PWD should have String type and String::from_value() should be OK()."
.into(),