Don't resolve symlinks in path add
This commit is contained in:
parent
c50f777c2b
commit
cf903a5b56
|
@ -66,7 +66,7 @@ export def --env "path add" [
|
||||||
"record" => { $p | get --ignore-errors $nu.os-info.name },
|
"record" => { $p | get --ignore-errors $nu.os-info.name },
|
||||||
}
|
}
|
||||||
|
|
||||||
$p | path expand
|
$p | path expand --no-symlink
|
||||||
}
|
}
|
||||||
|
|
||||||
if null in $paths or ($paths | is-empty) {
|
if null in $paths or ($paths | is-empty) {
|
||||||
|
@ -80,7 +80,6 @@ export def --env "path add" [
|
||||||
$env
|
$env
|
||||||
| get $path_name
|
| get $path_name
|
||||||
| split row (char esep)
|
| split row (char esep)
|
||||||
| path expand
|
|
||||||
| if $append { append $paths } else { prepend $paths }
|
| if $append { append $paths } else { prepend $paths }
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,32 @@ def path_add [] {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
def path_add_expand [] {
|
||||||
|
use std assert
|
||||||
|
|
||||||
|
# random paths to avoid collision, especially if left dangling on failure
|
||||||
|
let real_dir = $nu.temp-path | path join $"real-dir-(random chars)"
|
||||||
|
let link_dir = $nu.temp-path | path join $"link-dir-(random chars)"
|
||||||
|
mkdir $real_dir
|
||||||
|
let path_name = if $nu.os-info.family == 'windows' {
|
||||||
|
mklink /D $link_dir $real_dir
|
||||||
|
"Path"
|
||||||
|
} else {
|
||||||
|
ln -s $real_dir $link_dir | ignore
|
||||||
|
"PATH"
|
||||||
|
}
|
||||||
|
|
||||||
|
with-env {$path_name: []} {
|
||||||
|
def get_path [] { $env | get $path_name }
|
||||||
|
|
||||||
|
std path add $link_dir
|
||||||
|
assert equal (get_path) ([$link_dir])
|
||||||
|
}
|
||||||
|
|
||||||
|
rm $real_dir $link_dir
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
def banner [] {
|
def banner [] {
|
||||||
std assert ((std banner | lines | length) == 15)
|
std assert ((std banner | lines | length) == 15)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user