diff --git a/doc_src/cmds/path.rst b/doc_src/cmds/path.rst index b6a15bd82..e2a3d0324 100644 --- a/doc_src/cmds/path.rst +++ b/doc_src/cmds/path.rst @@ -277,7 +277,7 @@ Examples ``path resolve`` returns the normalized, physical and absolute versions of all paths. That means it resolves symlinks and does what ``path normalize`` does: it squashes duplicate "/" (except for two leading "//"), collapses "../" with earlier components and removes "." components. Then it turns that path into the absolute path starting from the filesystem root "/". -It is similar to ``realpath``, as it creates the "real", canonical version of the path. However, for nonexistent paths it will resolve as far as it can and normalize the nonexistent part. +It is similar to ``realpath``, as it creates the "real", canonical version of the path. However, for paths that can't be resolved, e.g. if they don't exist or form a symlink loop, it will resolve as far as it can and normalize the rest. It returns 0 if any normalization or resolution was done, i.e. any given path wasn't in canonical form. diff --git a/tests/checks/path.fish b/tests/checks/path.fish index 3f2aa2f48..4a5599d66 100644 --- a/tests/checks/path.fish +++ b/tests/checks/path.fish @@ -184,3 +184,17 @@ path sort --unique --what=basename {def,abc}/{456,123,789} def/{abc,def,0} abc/{ # CHECK: abc/foo + +# Symlink loop. +# It goes brrr. +ln -s target link +ln -s link target + +test (path resolve target) = (pwd -P)/target +and echo target resolves to target +# CHECK: target resolves to target + +test (path resolve link) = (pwd -P)/link +and echo link resolves to link +# CHECK: link resolves to link +