mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 03:15:00 +02:00
Fix path add
bug when given a record (#15379)
`path add`, when given a record, sets `$env.PATH` according to the value of the key matching `$nu.os-info.name`. There already existed a check in place to ensure the correct column existed, but it was never reached because of an early error on `path expand`ing `null`. This has been fixed, as well as the out-of-date reference to "darwin" instead of "macos" in the example. # User-Facing Changes `path add` now simply ignores a record that doesn't include a key for the current OS `path add` also will no longer add duplicate paths.
This commit is contained in:
@ -39,6 +39,12 @@ def path_add [] {
|
||||
path add $target_paths
|
||||
assert equal (get_path) ([($target_paths | get $nu.os-info.name)] | path expand)
|
||||
|
||||
load-env {$path_name: []}
|
||||
path add {}
|
||||
assert equal (get_path) []
|
||||
|
||||
assert error {|| path add 1 }
|
||||
|
||||
load-env {$path_name: [$"(["/foo", "/bar"] | path expand | str join (char esep))"]}
|
||||
path add "~/foo"
|
||||
assert equal (get_path) (["~/foo", "/foo", "/bar"] | path expand)
|
||||
|
@ -39,6 +39,12 @@ def path_add [] {
|
||||
path add $target_paths
|
||||
assert equal (get_path) ([($target_paths | get $nu.os-info.name)] | path expand)
|
||||
|
||||
load-env {$path_name: []}
|
||||
path add {}
|
||||
assert equal (get_path) ([])
|
||||
|
||||
assert error {|| path add 1 }
|
||||
|
||||
load-env {$path_name: [$"(["/foo", "/bar"] | path expand | str join (char esep))"]}
|
||||
path add "~/foo"
|
||||
assert equal (get_path) (["~/foo", "/foo", "/bar"] | path expand)
|
||||
|
Reference in New Issue
Block a user