From a0a27a5f4244c7260a1860263a78f05f3b494a6f Mon Sep 17 00:00:00 2001 From: RedLeaderOne Date: Tue, 6 Aug 2024 07:01:46 -0400 Subject: [PATCH] fix(script): ensure current directory is preserved during execution - Add pushd/popd to maintain the current working directory integrity - Remove unnecessary TMP_CWD variable and cd command Issue NMO-388 [skip release] --- src/utility_scripts/which_architecture_and_os.bash | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utility_scripts/which_architecture_and_os.bash b/src/utility_scripts/which_architecture_and_os.bash index 76677aa..b41ded5 100644 --- a/src/utility_scripts/which_architecture_and_os.bash +++ b/src/utility_scripts/which_architecture_and_os.bash @@ -23,6 +23,7 @@ # exit 1 in case of unsupported processor architecture # # ================================================================================================= +pushd "$(pwd)" >/dev/null || exit 1 # ....Pre-condition................................................................................ if [[ "$(basename "$(pwd)")" != "utility_scripts" ]]; then @@ -33,8 +34,6 @@ if [[ "$(basename "$(pwd)")" != "utility_scripts" ]]; then fi # ....Load helper function......................................................................... -TMP_CWD=$(pwd) - # (Priority) ToDo: validate!! (ref task NMO-388 fix: explicitly sourcing .env.n2st cause conflicting problem when the repo is used as a lib) if [[ -z $PROJECT_PROMPT_NAME ]] && [[ -z $PROJECT_GIT_NAME ]] ; then set -o allexport @@ -45,8 +44,9 @@ fi cd ../function_library || exit 1 source ./general_utilities.bash -cd "${TMP_CWD}" # ====Begin======================================================================================== n2st::set_which_architecture_and_os +# ====Teardown===================================================================================== +popd >/dev/null || exit 1