From 71539fb9065fb6ddd29fca88798ca79b22ec5f49 Mon Sep 17 00:00:00 2001 From: spezi Date: Fri, 22 Mar 2024 07:12:18 +0100 Subject: [PATCH] more robust references to script directory --- logger.sh | 4 +++- math.sh | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/logger.sh b/logger.sh index b2ad306..d7cf5d0 100644 --- a/logger.sh +++ b/logger.sh @@ -1,6 +1,8 @@ #!/bin/bash -. /home/spezi/Scripts/utils/colors.sh +# https://stackoverflow.com/a/246128 +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +. $SCRIPT_DIR/colors.sh logger () { echo -e "${NC}$(date) - [$BASHPID] - [${0##*/}] - $@${NC}" diff --git a/math.sh b/math.sh index 66fceef..07806dc 100644 --- a/math.sh +++ b/math.sh @@ -1,6 +1,8 @@ #!/bin/bash -DIRECTORY=$(cd `dirname $0` && pwd) -. /home/spezi/Scripts/utils/utils.sh + +# https://stackoverflow.com/a/246128 +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +. $SCRIPT_DIR/utils.sh # https://unix.stackexchange.com/questions/66766/float-operation-with-bc # https://unix.stackexchange.com/questions/89712/how-to-convert-floating-point-number-to-integer