From 0453acbbd45604537090ec7a3295b34309e6eecb Mon Sep 17 00:00:00 2001 From: Andrey Mozzhuhin Date: Sat, 16 Jan 2021 11:18:41 +0300 Subject: toolchain-shar-extract.sh: Handle special characters in script path Extracting SDK archive may fail if the script is run using a path with special characters such as space or asterisk. This is because the shell interprets such characters after expanding the $0 variable. Added quotes to all uses of the shell variable $0 to fix this. Signed-off-by: Andrey Mozzhuhin Signed-off-by: Richard Purdie --- meta/files/toolchain-shar-extract.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'meta') diff --git a/meta/files/toolchain-shar-extract.sh b/meta/files/toolchain-shar-extract.sh index bea6d4189a..dd9342758b 100644 --- a/meta/files/toolchain-shar-extract.sh +++ b/meta/files/toolchain-shar-extract.sh @@ -95,7 +95,7 @@ while getopts ":yd:npDRSl" OPT; do listcontents=1 ;; *) - echo "Usage: $(basename $0) [-y] [-d ]" + echo "Usage: $(basename "$0") [-y] [-d ]" echo " -y Automatic yes to all prompts" echo " -d Install the SDK to " echo "======== Extensible SDK only options ============" @@ -111,17 +111,17 @@ while getopts ":yd:npDRSl" OPT; do esac done -payload_offset=$(($(grep -na -m1 "^MARKER:$" $0|cut -d':' -f1) + 1)) +payload_offset=$(($(grep -na -m1 "^MARKER:$" "$0"|cut -d':' -f1) + 1)) if [ "$listcontents" = "1" ] ; then if [ @SDK_ARCHIVE_TYPE@ = "zip" ]; then - tail -n +$payload_offset $0 > sdk.zip + tail -n +$payload_offset "$0" > sdk.zip if unzip -l sdk.zip;then rm sdk.zip else rm sdk.zip && exit 1 fi else - tail -n +$payload_offset $0| tar tvJ || exit 1 + tail -n +$payload_offset "$0"| tar tvJ || exit 1 fi exit fi @@ -242,14 +242,14 @@ fi printf "Extracting SDK..." if [ @SDK_ARCHIVE_TYPE@ = "zip" ]; then - tail -n +$payload_offset $0 > sdk.zip + tail -n +$payload_offset "$0" > sdk.zip if $SUDO_EXEC unzip $EXTRA_TAR_OPTIONS sdk.zip -d $target_sdk_dir;then rm sdk.zip else rm sdk.zip && exit 1 fi else - tail -n +$payload_offset $0| $SUDO_EXEC tar mxJ -C $target_sdk_dir --checkpoint=.2500 $EXTRA_TAR_OPTIONS || exit 1 + tail -n +$payload_offset "$0"| $SUDO_EXEC tar mxJ -C $target_sdk_dir --checkpoint=.2500 $EXTRA_TAR_OPTIONS || exit 1 fi echo "done" -- cgit 1.2.3-korg