Skip to content

Commit eae736e

Browse files
committed
fix: avoid polluting the global namespace
Signed-off-by: Wenxuan Zhang <[email protected]>
1 parent 63fd2ba commit eae736e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

forgit.plugin.zsh

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,19 @@ if [[ -n "$ZSH_VERSION" ]]; then
1010
0="${ZERO:-${${0:#$ZSH_ARGZERO}:-${(%):-%N}}}"
1111
# shellcheck disable=2277,2296,2298
1212
0="${${(M)0:#/*}:-$PWD/$0}"
13-
INSTALL_DIR="${0:h}"
13+
FORGIT_INSTALL_DIR="${0:h}"
1414
elif [[ -n "$BASH_VERSION" ]]; then
15-
INSTALL_DIR="$(dirname -- "${BASH_SOURCE[0]}")"
15+
FORGIT_INSTALL_DIR="$(dirname -- "${BASH_SOURCE[0]}")"
1616
else
1717
forgit::error "Only zsh and bash are supported"
1818
fi
19-
FORGIT="$INSTALL_DIR/bin/git-forgit"
19+
20+
export FORGIT_INSTALL_DIR
21+
FORGIT="$FORGIT_INSTALL_DIR/bin/git-forgit"
2022

2123
# backwards compatibility:
2224
# export all user-defined FORGIT variables to make them available in git-forgit
23-
unexported_vars=0
25+
local unexported_vars=0
2426
# Set posix mode in bash to only get variables, see #256.
2527
[[ -n "$BASH_VERSION" ]] && set -o posix
2628
set | awk -F '=' '{ print $1 }' | grep FORGIT_ | while read -r var; do
@@ -130,8 +132,6 @@ forgit::ignore::clean() {
130132
"$FORGIT" ignore_clean "$@"
131133
}
132134

133-
export FORGIT_INSTALL_DIR=$INSTALL_DIR
134-
135135
# register aliases
136136
# shellcheck disable=SC2139
137137
if [[ -z "$FORGIT_NO_ALIASES" ]]; then

0 commit comments

Comments
 (0)