Fix case when target is not a symlink

This commit is contained in:
Nero 2018-03-13 23:45:19 +00:00
parent 256ef33bdf
commit 79a20986eb
2 changed files with 7 additions and 1 deletions

View File

@ -4,6 +4,7 @@ target=$(readlink "$p")
case "$target" in
/*) p="$target";;
'') ;;
*) p="${p%/*}/$target";;
esac

View File

@ -10,7 +10,11 @@ do_test() {
*/*) mkdir -p "${name%/*}";;
esac
ln -s "$target" "$name"
if [ -n "$target" ]; then
ln -s "$target" "$name"
else
touch "$name"
fi
is=$($bin "$name")
@ -31,5 +35,6 @@ do_test 1 a /bin
do_test 2 a/b .
do_test 3 a/b ..
do_test 4 a/b ../t
do_test 5 a
rm -rf "$dir"