fix: compatibility check not working in bash (#258)

Fix: backwards compatibility check not working reliably in bash
This commit is contained in:
Markus Meier 2022-12-09 09:54:58 +01:00 committed by GitHub
parent 4b251aab22
commit bfea8cf485
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -21,8 +21,10 @@ FORGIT="$INSTALL_DIR/bin/git-forgit"
# backwards compatibility:
# export all user-defined FORGIT variables to make them available in git-forgit
unexported_vars=0
# Set posix mode in bash to only get variables, see #256.
[[ -n "$BASH_VERSION" ]] && set -o posix
set | awk -F '=' '{ print $1 }' | grep FORGIT_ | while read -r var; do
if ! export | grep -q "^$var="; then
if ! export | grep -q "\(^$var=\|^export $var=\)"; then
if [[ $unexported_vars == 0 ]]; then
forgit::warn "Config options have to be exported in future versions of forgit."
forgit::warn "Please update your config accordingly:"
@ -33,6 +35,7 @@ set | awk -F '=' '{ print $1 }' | grep FORGIT_ | while read -r var; do
export "$var"
fi
done
[[ -n "$BASH_VERSION" ]] && set +o posix
# register shell functions
forgit::log() {