mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-07 10:01:14 -03:00
path: Make path real "work" with nonexistent paths
This just goes back until it finds an existent path, resolves that, and adds the normalized rest on top. So if you try /bin/foo/bar////../baz and /bin exists as a symlink to /usr/bin, it would resolve that, and normalize the rest, giving /usr/bin/foo/baz (note: We might want to add this to realpath as well?)
This commit is contained in:
@@ -110,3 +110,14 @@ path real bin//sh | string match -r -- 'bin/bash$'
|
||||
# The "//" is squashed, and the symlink is resolved.
|
||||
# sh here is bash
|
||||
# CHECK: bin/bash
|
||||
|
||||
# `path real` with nonexistent paths
|
||||
set -l path (path real foo/bar)
|
||||
string match -rq "^"(string escape --style=regex -- $PWD)'/' -- $path
|
||||
and echo It matches pwd!
|
||||
# CHECK: It matches pwd!
|
||||
string replace -r "^"(string escape --style=regex -- $PWD)'/' "" -- $path
|
||||
# CHECK: foo/bar
|
||||
|
||||
path real /banana//terracota/terracota/booooo/../pie
|
||||
# CHECK: /banana/terracota/terracota/pie
|
||||
|
||||
Reference in New Issue
Block a user