forked from extern/nushell
Fix cd'ing to symlinked directories (#1651)
* fix: absolutize path against its parent if it was a symlink. On Linux this happens because Rust calls readlink but doesn't canonicalize the resultant path. * feat: playground function to create symlinks * fix: use playground dirs * feat: test for #1631, shift tests names
This commit is contained in:
committed by
GitHub
parent
e7a4f31b38
commit
846a779516
@ -49,12 +49,16 @@ where
|
||||
P: AsRef<Path>,
|
||||
Q: AsRef<Path>,
|
||||
{
|
||||
let canonicalized = absolutize(relative_to, path);
|
||||
let path = match std::fs::read_link(&canonicalized) {
|
||||
Ok(resolved) => resolved,
|
||||
let absolutized = absolutize(&relative_to, path);
|
||||
let path = match std::fs::read_link(&absolutized) {
|
||||
Ok(resolved) => {
|
||||
let parent = absolutized.parent().unwrap_or(&absolutized);
|
||||
absolutize(parent, resolved)
|
||||
}
|
||||
|
||||
Err(e) => {
|
||||
if canonicalized.exists() {
|
||||
canonicalized
|
||||
if absolutized.exists() {
|
||||
absolutized
|
||||
} else {
|
||||
return Err(e);
|
||||
}
|
||||
|
Reference in New Issue
Block a user