Skip to content
This repository has been archived by the owner on Sep 8, 2021. It is now read-only.

Commit

Permalink
sometimes popd was called without any previous pushd
Browse files Browse the repository at this point in the history
  • Loading branch information
mammo0 committed Jul 30, 2020
1 parent 3b57281 commit 50ed586
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions build_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ set -e
# the variables are stored in an .env file that is created by 0_prepare.sh
if [ ! -f ".env" ]; then
echo "Please run 0_prepare.sh first!" >&2
exit 1
return 1
fi
# source .env file
. .env
Expand All @@ -31,15 +31,23 @@ fi
# this function should be called when entering the environment
function _enter() {
pushd "$BASE_DIR"

# mark the entering process as complete
export BUILD_ENV_ENTERED="true"
}

# this function should be called when leaving the environment
function _leave() {
# remove the temporary directory
rm -rf "$TMP_DIR"

# equivalent to the pushd in the _enter function
popd
# the following steps should only be taken if _enter was called before
if [ "$BUILD_ENV_ENTERED" = "true" ]; then
# equivalent to the pushd in the _enter function
popd

unset BUILD_ENV_ENTERED
fi
}

# try to call the 'build' function
Expand Down

0 comments on commit 50ed586

Please # to comment.