mirror of
https://github.com/wfxr/forgit.git
synced 2026-09-14 09:16:16 -04:00
fix: avoid polluting the global namespace (#347)
Signed-off-by: Wenxuan Zhang <wenxuangm@gmail.com>
This commit is contained in:
parent
2eda2a457a
commit
714f6dfec1
|
|
@ -10,13 +10,15 @@ if [[ -n "$ZSH_VERSION" ]]; then
|
|||
0="${ZERO:-${${0:#$ZSH_ARGZERO}:-${(%):-%N}}}"
|
||||
# shellcheck disable=2277,2296,2298
|
||||
0="${${(M)0:#/*}:-$PWD/$0}"
|
||||
INSTALL_DIR="${0:h}"
|
||||
FORGIT_INSTALL_DIR="${0:h}"
|
||||
elif [[ -n "$BASH_VERSION" ]]; then
|
||||
INSTALL_DIR="$(dirname -- "${BASH_SOURCE[0]}")"
|
||||
FORGIT_INSTALL_DIR="$(dirname -- "${BASH_SOURCE[0]}")"
|
||||
else
|
||||
forgit::error "Only zsh and bash are supported"
|
||||
fi
|
||||
FORGIT="$INSTALL_DIR/bin/git-forgit"
|
||||
|
||||
export FORGIT_INSTALL_DIR
|
||||
FORGIT="$FORGIT_INSTALL_DIR/bin/git-forgit"
|
||||
|
||||
# backwards compatibility:
|
||||
# export all user-defined FORGIT variables to make them available in git-forgit
|
||||
|
|
@ -35,6 +37,7 @@ set | awk -F '=' '{ print $1 }' | grep FORGIT_ | while read -r var; do
|
|||
export "$var"
|
||||
fi
|
||||
done
|
||||
unset unexported_vars
|
||||
[[ -n "$BASH_VERSION" ]] && set +o posix
|
||||
|
||||
# register shell functions
|
||||
|
|
@ -130,8 +133,6 @@ forgit::ignore::clean() {
|
|||
"$FORGIT" ignore_clean "$@"
|
||||
}
|
||||
|
||||
export FORGIT_INSTALL_DIR=$INSTALL_DIR
|
||||
|
||||
# register aliases
|
||||
# shellcheck disable=SC2139
|
||||
if [[ -z "$FORGIT_NO_ALIASES" ]]; then
|
||||
|
|
|
|||
Loading…
Reference in a new issue