From 083d30a0c3e9f3894912977fbbf2a60cdc7f474e Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Thu, 5 Feb 2026 22:55:27 +0200 Subject: [PATCH] fix(scripts): fix shared.sh guard logic and echo -e portability - shared.sh: simplify guard logic, remove misleading warning message, use ${VAR:-} pattern to avoid unbound variable error - install-cheat-purebashbible.sh: replace echo -e with printf for POSIX portability --- scripts/install-cheat-purebashbible.sh | 2 +- scripts/shared.sh | 15 +++------------ 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/scripts/install-cheat-purebashbible.sh b/scripts/install-cheat-purebashbible.sh index 4961cbf..fc6606a 100755 --- a/scripts/install-cheat-purebashbible.sh +++ b/scripts/install-cheat-purebashbible.sh @@ -86,7 +86,7 @@ process_chapters() if [ '---' != "$(head -1 < "$cheat_file")" ]; then local metadata metadata="$PBB_SYNTAX\n$PBB_TAGS\n$PBB_SOURCE\n" - echo -e "---\n$metadata---\n$(cat "$cheat_file")" > "$cheat_file" + printf '%s\n%b%s\n%s' "---" "$metadata" "---" "$(cat "$cheat_file")" > "$cheat_file" fi done } diff --git a/scripts/shared.sh b/scripts/shared.sh index c8b132c..5baf586 100755 --- a/scripts/shared.sh +++ b/scripts/shared.sh @@ -4,17 +4,8 @@ # Helper env variables. Use like this: VERBOSE=1 ./script.sh : "${VERBOSE:=0}" -# Set variable that checks if the shared.sh script has been -# sourced only once If the script has been sourced more than once, -# the script not be sourced again. -[ -z "$SHARED_SCRIPTS_SOURCED" ] && { - +# Source the main shared config if not already loaded +if [ -z "${SHARED_SCRIPTS_SOURCED:-}" ]; then source "${DOTFILES}/config/shared.sh" - # Warn the user if the shared configuration hasn't been loaded yet - msgr warn "(!) shared.sh not sourced" - - # Set variable that checks if the shared.sh script has been - # sourced only once. - # shellcheck disable=SC2034 export SHARED_SCRIPTS_SOURCED=1 -} +fi