From deacdc6febe7699335a21e119c7bf38ec7aaa1ed Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 26 Apr 2025 00:33:34 +0200 Subject: [PATCH] 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 --- scripts/with-go-mod.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/scripts/with-go-mod.sh b/scripts/with-go-mod.sh index 6508f3935b..3b9c9dd805 100755 --- a/scripts/with-go-mod.sh +++ b/scripts/with-go-mod.sh @@ -17,14 +17,12 @@ create_symlink() { local target="$1" local link="$2" - if [ -L "$link" ] && [ "$(readlink "$link")" = "$target" ]; then - # symlink already present; we're done - return - fi - if [ -e "$link" ]; then - echo "$(basename "$0"): WARN: $link exists but is not the expected symlink!" >&2 - echo "$(basename "$0"): WARN: Using your version instead of our generated version -- this may misbehave!" >&2 + # see https://superuser.com/a/196698 + if ! [ "$link" -ef "${ROOTDIR}/${target}" ]; then + echo "$(basename "$0"): WARN: $link exists but is not the expected symlink!" >&2 + echo "$(basename "$0"): WARN: Using your version instead of our generated version -- this may misbehave!" >&2 + fi return fi