From a286451d8f6fab57e61e779d37a8dff29260cf3e Mon Sep 17 00:00:00 2001 From: "Gal Szkolnik (@bobo)" Date: Mon, 20 Nov 2023 17:48:43 -0500 Subject: [PATCH] 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. --- fix-kubectl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fix-kubectl b/fix-kubectl index 077b25e..0c86bb4 100755 --- a/fix-kubectl +++ b/fix-kubectl @@ -1,4 +1,8 @@ #! /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_SHELL="$(basename "$SHELL")" if [[ -z "${BASE_0}" || "${BASE_0}" == "$BASE_SHELL" ]]; then @@ -80,6 +84,7 @@ if [[ -z "${BASE_0}" || "${BASE_0}" == "$BASE_SHELL" ]]; then } fi elif [[ "$1" == '-' ]]; then + printf '%s\n' "SCRIPT_FULL_PATH='$SCRIPT_DIR/$BASE_0'" cat "${BASH_SOURCE[0]}" else SCRIPT_NAME="$BASE_0"