From a2373f2056c585895f8ca404fe4af0aa4eb9cb1b Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Fri, 18 Mar 2022 18:17:00 +0100 Subject: [PATCH] Improve bootstrap-haskell and fix shellcheck warnings --- scripts/bootstrap/bootstrap-haskell | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/bootstrap/bootstrap-haskell b/scripts/bootstrap/bootstrap-haskell index 18604c8..f4e621f 100755 --- a/scripts/bootstrap/bootstrap-haskell +++ b/scripts/bootstrap/bootstrap-haskell @@ -197,12 +197,15 @@ posix_realpath() { current_loop=0 max_loops=50 mysource=$1 + # readlink and '[ -h $path ]' behave different wrt '/sbin/' and '/sbin', so we strip it + mysource=${mysource%/} + [ -z "${mysource}" ] && mysource=$1 while [ -h "${mysource}" ]; do current_loop=$((current_loop+1)) mydir="$( cd -P "$( dirname "${mysource}" )" > /dev/null 2>&1 && pwd )" mysource="$(readlink "${mysource}")" - [ "${mysource%${mysource#?}}"x != '/x' ] && mysource="${mydir}/${mysource}" + [ "${mysource%"${mysource#?}"}"x != '/x' ] && mysource="${mydir%/}/${mysource}" if [ ${current_loop} -gt ${max_loops} ] ; then (>&2 echo "${1}: Too many levels of symbolic links")