mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-08 10:51:15 -03:00
resolve: Normalize
This means "../" components are cancelled out even after non-existent paths or files. (the alternative is to error out, but being able to say `path resolve /path/to/file/../../` over `path resolve (path dirname /path/to/file)/../../` seems worth it?)
This commit is contained in:
@@ -118,6 +118,10 @@ path resolve bin//sh | string match -r -- 'bin/bash$'
|
||||
# sh here is bash
|
||||
# CHECK: bin/bash
|
||||
|
||||
# "../" cancels out even files.
|
||||
path resolve bin//sh/../ | string match -r -- 'bin$'
|
||||
# CHECK: bin
|
||||
|
||||
# `path resolve` with nonexistent paths
|
||||
set -l path (path resolve foo/bar)
|
||||
string match -rq "^"(pwd -P | string escape --style=regex)'/' -- $path
|
||||
|
||||
Reference in New Issue
Block a user