-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
90d8c44
commit 9d337d5
Showing
2 changed files
with
97 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,64 @@ | ||
#!/usr/bin/env sh | ||
|
||
# set the active shell as the detected POSIX (.sh) shell | ||
# do not export | ||
if [ -n "${BASH_VERSION-}" ]; then | ||
ACTIVE_POSIX_SHELL='bash' | ||
elif [ -n "${ZSH_VERSION-}" ]; then | ||
ACTIVE_POSIX_SHELL='zsh' | ||
elif [ "$0" = '-dash' ] || [ "$0" = 'dash' ]; then | ||
# dash does not define DASH_VERSION | ||
ACTIVE_POSIX_SHELL='dash' | ||
elif [ -n "${KSH_VERSION-}" ]; then | ||
ACTIVE_POSIX_SHELL='ksh' | ||
else | ||
ACTIVE_POSIX_SHELL='sh' | ||
# # set the active shell as the detected POSIX (.sh) shell | ||
# # do not export | ||
# if [ -n "${BASH_VERSION-}" ]; then | ||
# ACTIVE_POSIX_SHELL='bash' | ||
# elif [ -n "${ZSH_VERSION-}" ]; then | ||
# ACTIVE_POSIX_SHELL='zsh' | ||
# elif [ "$0" = '-dash' ] || [ "$0" = 'dash' ]; then | ||
# # dash does not define DASH_VERSION | ||
# ACTIVE_POSIX_SHELL='dash' | ||
# elif [ -n "${KSH_VERSION-}" ]; then | ||
# ACTIVE_POSIX_SHELL='ksh' | ||
# else | ||
# ACTIVE_POSIX_SHELL='sh' | ||
# fi | ||
|
||
# setup new env | ||
if [ "$LOAD_EXISTING_CACHE_SUCCESS" = 'no' ]; then | ||
echo "load " | ||
eval "$( | ||
"$DOROTHY/commands/setup-environment-commands" "$ACTIVE_POSIX_SHELL" || { | ||
echo "DOROTHY FAILED TO SETUP ENVIRONMENT, RUN THIS TO DEBUG: bash -x '$DOROTHY/commands/setup-environment-commands' '$ACTIVE_POSIX_SHELL'" >/dev/stderr | ||
return 1 | ||
} | ||
)" | ||
fi | ||
|
||
if [ "$LOAD_EXISTING_CACHE_SUCCESS" = 'yes' ]; then | ||
# process previous env | ||
pairs_formatted="$(echo "$PREV_ENV_KEY_VALUES" | tr '\n' ' ')" | ||
# echo "$pairs_formatted" | ||
eval "$( | ||
env "$pairs_formatted" \ | ||
"$DOROTHY/commands/setup-environment-commands" "$ACTIVE_POSIX_SHELL" || { | ||
echo "DOROTHY FAILED TO SETUP ENVIRONMENT, RUN THIS TO DEBUG: bash -x '$DOROTHY/commands/setup-environment-commands' '$ACTIVE_POSIX_SHELL'" >/dev/stderr | ||
return 1 | ||
} | ||
)" | ||
fi | ||
|
||
# set the environment variables | ||
eval "$("$DOROTHY/commands/setup-environment-commands" "$ACTIVE_POSIX_SHELL" || { | ||
echo "DOROTHY FAILED TO SETUP ENVIRONMENT, RUN THIS TO DEBUG: bash -x '$DOROTHY/commands/setup-environment-commands' '$ACTIVE_POSIX_SHELL'" >/dev/stderr | ||
return 1 | ||
})" | ||
# # env '' should be completely redundant with no unforseen consequences, so we | ||
# # can achieve the conditional loading of setup-environment-commands based | ||
# # on the cache with the following | ||
# [ "$LOAD_EXISTING_CACHE_SUCCESS" = 'yes' ] && | ||
# pairs_formatted="$(echo "$PREV_ENV_KEY_VALUES" | tr '\n' ' ')" || pairs_formatted='' | ||
# # if [ "$LOAD_EXISTING_CACHE_SUCCESS" = 'yes' ]; then | ||
# # process previous env | ||
# # pairs_formatted="$(echo "$PREV_ENV_KEY_VALUES" | tr '\n' ' ')" | ||
# # echo "$pairs_formatted" | ||
# eval "$( | ||
# env "$pairs_formatted" \ | ||
# "$DOROTHY/commands/setup-environment-commands" "$ACTIVE_POSIX_SHELL" || { | ||
# echo "DOROTHY FAILED TO SETUP ENVIRONMENT, RUN THIS TO DEBUG: bash -x '$DOROTHY/commands/setup-environment-commands' '$ACTIVE_POSIX_SHELL'" >/dev/stderr | ||
# return 1 | ||
# } | ||
# )" | ||
# # fi | ||
|
||
# save cache | ||
if [ ! -f "$PATH_ENV_CACHE" ]; then | ||
touch "$PATH_ENV_CACHE" | ||
fi | ||
export -p >"$PATH_ENV_CACHE" |