Fix more inconsistent behaviour with symlinks in paths.

Both redo and minimal/do were doing slightly weird things with
symlinked directories, especially when combined with "..".  For
example, if x is a link to ., then x/x/x/x/../y should resolve to
"../y", which is quite non-obvious.

Added some tests to make sure this stays fixed.
This commit is contained in:
Avery Pennarun 2018-12-17 15:58:06 +00:00
commit 686c381109
13 changed files with 121 additions and 8 deletions

View file

@ -130,6 +130,17 @@ check ".." _normpath ../ "$x"
check ".." _normpath .. "$x"
SECTION _realpath
rm -rf y
mkdir y
ln -s . y/x
check "/usr/__does_not/b" _realpath "/usr/__does_not/a/../b" "$x"
check "foo" _realpath "y/x/x/x/x/x/../foo" "$PWD"
check "$(/bin/pwd)/foo" _realpath "$PWD/y/x/x/x/x/x/../foo" "$PWD"
check "foo/blam" _realpath "y/x/x/x/x/x/../foo/spam/../blam" "$PWD"
check "$(/bin/pwd)/foo/blam" _realpath "$PWD/y/x/x/../foo/spam/../blam" "$PWD"
SECTION _find_dofile
check "test.do" _find_dofiles test
check "test.do" _find_dofile test