Skip to content

Commit 4464134

Browse files
committed
scripts/with-go-mod.sh: simplify symlink comparison
Make sure the symlinks point to the same file; not if both are identical (absolute or relative symlink); it's only for suppressing the warning so not critical. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 537acbe commit 4464134

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

scripts/with-go-mod.sh

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@ create_symlink() {
1717
local target="$1"
1818
local link="$2"
1919

20-
if [ -L "$link" ] && [ "$(readlink "$link")" = "$target" ]; then
21-
# symlink already present; we're done
22-
return
23-
fi
24-
2520
if [ -e "$link" ]; then
26-
echo "$(basename "$0"): WARN: $link exists but is not the expected symlink!" >&2
27-
echo "$(basename "$0"): WARN: Using your version instead of our generated version -- this may misbehave!" >&2
21+
# see https://superuser.com/a/196698
22+
if ! [ "$link" -ef "${ROOTDIR}/${target}" ]; then
23+
echo "$(basename "$0"): WARN: $link exists but is not the expected symlink!" >&2
24+
echo "$(basename "$0"): WARN: Using your version instead of our generated version -- this may misbehave!" >&2
25+
fi
2826
return
2927
fi
3028

0 commit comments

Comments
 (0)