mirror of
https://github.com/nushell/nushell
synced 2024-11-14 08:57:08 +00:00
If path to cd given. Report the error with the path given.
This commit is contained in:
parent
6a8dddedc3
commit
a449d2c005
1 changed files with 11 additions and 1 deletions
|
@ -82,7 +82,9 @@ impl Shell for ValueShell {
|
|||
}
|
||||
|
||||
fn cd(&self, args: EvaluatedWholeStreamCommandArgs) -> Result<OutputStream, ShellError> {
|
||||
let path = match args.nth(0) {
|
||||
let destination = args.nth(0);
|
||||
|
||||
let path = match destination {
|
||||
None => "/".to_string(),
|
||||
Some(v) => {
|
||||
let target = v.as_path()?;
|
||||
|
@ -108,6 +110,14 @@ impl Shell for ValueShell {
|
|||
value_system.walk_decorate(&self.value)?;
|
||||
|
||||
if !value_system.exists(&PathBuf::from(&path)) {
|
||||
if let Some(destination) = destination {
|
||||
return Err(ShellError::labeled_error(
|
||||
"Can not change to path inside",
|
||||
"No such path exists",
|
||||
destination.span(),
|
||||
));
|
||||
}
|
||||
|
||||
return Err(ShellError::labeled_error(
|
||||
"Can not change to path inside",
|
||||
"No such path exists",
|
||||
|
|
Loading…
Reference in a new issue