mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 14:40:06 +02:00
Fix cp bug (#5462)
* Cleanup - remove old commented code * Force a / or \ to distinguish between folders and files for cp * Force a / or \ to distinguish between folders and files for cp * Remove unneeded code * Add cp test for checking copy to non existing directory * Fix warning in test
This commit is contained in:
committed by
GitHub
parent
aa88449f29
commit
2cc5952c37
@ -14,6 +14,9 @@ fn expand_tilde_with_home(path: impl AsRef<Path>, home: Option<PathBuf>) -> Path
|
||||
};
|
||||
}
|
||||
|
||||
let path_last_char = path.as_os_str().to_string_lossy().chars().last();
|
||||
let need_trailing_slash = path_last_char == Some('/') || path_last_char == Some('\\');
|
||||
|
||||
match home {
|
||||
None => path.into(),
|
||||
Some(mut h) => {
|
||||
@ -31,6 +34,10 @@ fn expand_tilde_with_home(path: impl AsRef<Path>, home: Option<PathBuf>) -> Path
|
||||
if p != Path::new("") {
|
||||
h.push(p)
|
||||
}
|
||||
|
||||
if need_trailing_slash {
|
||||
h.push("");
|
||||
}
|
||||
}
|
||||
h
|
||||
}
|
||||
|
Reference in New Issue
Block a user