From bfea8cf48523b3d6fa72d131e81769b68f43e3a7 Mon Sep 17 00:00:00 2001 From: Markus Meier Date: Fri, 9 Dec 2022 09:54:58 +0100 Subject: [PATCH] fix: compatibility check not working in bash (#258) Fix: backwards compatibility check not working reliably in bash --- forgit.plugin.zsh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/forgit.plugin.zsh b/forgit.plugin.zsh index 21bf56c..84696ee 100755 --- a/forgit.plugin.zsh +++ b/forgit.plugin.zsh @@ -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() {