fixed kubectl-fix

recalling the script would always fail because the script's path would
not persist, passing the complete path into the source call (.) solved
this issue.
This commit is contained in:
Gal Szkolnik (@bobo) 2023-11-20 17:48:43 -05:00
parent e179df0b48
commit a286451d8f
1 changed files with 5 additions and 0 deletions

View File

@ -1,4 +1,8 @@
#! /usr/bin/env bash #! /usr/bin/env bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
USER_HOME=$HOME
[[ -n "${SUDO_USER}" ]] && USER_HOME="$(eval "echo ~${SUDO_USER}")"
BASE_0="$(basename ${0#-})" BASE_0="$(basename ${0#-})"
BASE_SHELL="$(basename "$SHELL")" BASE_SHELL="$(basename "$SHELL")"
if [[ -z "${BASE_0}" || "${BASE_0}" == "$BASE_SHELL" ]]; then if [[ -z "${BASE_0}" || "${BASE_0}" == "$BASE_SHELL" ]]; then
@ -80,6 +84,7 @@ if [[ -z "${BASE_0}" || "${BASE_0}" == "$BASE_SHELL" ]]; then
} }
fi fi
elif [[ "$1" == '-' ]]; then elif [[ "$1" == '-' ]]; then
printf '%s\n' "SCRIPT_FULL_PATH='$SCRIPT_DIR/$BASE_0'"
cat "${BASH_SOURCE[0]}" cat "${BASH_SOURCE[0]}"
else else
SCRIPT_NAME="$BASE_0" SCRIPT_NAME="$BASE_0"