From 2b803a2cb6c0decc40473f72fb470fa5ebf653d5 Mon Sep 17 00:00:00 2001 From: Roni Laukkarinen Date: Wed, 13 Nov 2024 23:10:58 +0200 Subject: [PATCH] Fix newtheme-popos.sh script location detection --- CHANGELOG.md | 1 + bin/newtheme-popos.sh | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a11ff03..598493dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ### Unreleased * Demo: Prevent spaces in theme-info link +* Fix newtheme-popos.sh script location detection ### 9.4.5: 2024-10-25 diff --git a/bin/newtheme-popos.sh b/bin/newtheme-popos.sh index 9e65d766..7cb9d03c 100644 --- a/bin/newtheme-popos.sh +++ b/bin/newtheme-popos.sh @@ -9,7 +9,7 @@ SCRIPT_VERSION='1.0.0 (2023-09-29)' CURRENTFILE=`basename $0` # Determine scripts location to get imports right -if [ "$CURRENTFILE" = "newtheme.sh" ]; then +if [ "$CURRENTFILE" = "newtheme-popos.sh" ]; then SCRIPTS_LOCATION="$( pwd )" source ${SCRIPTS_LOCATION}/tasks/variables.sh source ${SCRIPTS_LOCATION}/tasks/header.sh @@ -17,7 +17,13 @@ if [ "$CURRENTFILE" = "newtheme.sh" ]; then else DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" ORIGINAL_FILE=$( readlink $DIR/$CURRENTFILE ) - SCRIPTS_LOCATION=$( dirname $ORIGINAL_FILE ) + # Check if ORIGINAL_FILE is empty before calling dirname + if [ -n "$ORIGINAL_FILE" ]; then + SCRIPTS_LOCATION=$( dirname "$ORIGINAL_FILE" ) + else + echo "Error: Could not determine original file location" + exit 1 + fi fi # Final note about server requirements