Test and document symlink loop

This commit is contained in:
Fabian Homborg 2022-05-19 21:08:11 +02:00
parent b6ebf15c75
commit e87ad48f9b
2 changed files with 15 additions and 1 deletions

View file

@ -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.

View file

@ -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