diff --git a/bin/git-forgit b/bin/git-forgit index c45ab56..1b3b9de 100755 --- a/bin/git-forgit +++ b/bin/git-forgit @@ -314,10 +314,11 @@ _forgit_cherry_pick() { [[ $fzf_exitval != 0 ]] && return $fzf_exitval [[ -z "$fzf_selection" ]] && return $fzf_exitval - old_IFS=$IFS IFS=$'\n' + ${IFS+"false"} && unset old_IFS || old_IFS="$IFS" + IFS=$'\n' # shellcheck disable=2207 commits=($(echo "$fzf_selection" | sort --numeric-sort --key=1 | cut -f2 | cut -d' ' -f1 | _forgit_reverse_lines)) - IFS=${old_IFS} + ${old_IFS+"false"} && unset IFS || IFS="$old_IFS" [ ${#commits[@]} -eq 0 ] && return 1 $git_cherry_pick "${commits[@]}" @@ -553,7 +554,8 @@ _forgit_revert_commit() { files=$(sed -nE 's/.* -- (.*)/\1/p' <<< "$*") # extract files parameters for `git show` command preview="echo {} | cut -f2- | $_forgit_extract_sha | xargs -I% git show --color=always % -- $files | $_forgit_show_pager" - old_IFS=$IFS IFS=$'\n' + ${IFS+"false"} && unset old_IFS || old_IFS="$IFS" + IFS=$'\n' # shellcheck disable=2207 commits=($(eval "$cmd" | nl | @@ -561,7 +563,7 @@ _forgit_revert_commit() { sort --numeric-sort --key=1 | cut -f2- | sed 's/^[^a-f^0-9]*\([a-f0-9]*\).*/\1/')) - IFS=${old_IFS} + ${old_IFS+"false"} && unset IFS || IFS="$old_IFS" [ ${#commits[@]} -eq 0 ] && return 1 @@ -607,11 +609,12 @@ _forgit_ignore() { --preview=\"eval $cmd\" $FORGIT_IGNORE_FZF_OPTS " - old_IFS=$IFS IFS=$'\n' + ${IFS+"false"} && unset old_IFS || old_IFS="$IFS" + IFS=$'\n' # shellcheck disable=SC2206,2207 args=($@) && [[ $# -eq 0 ]] && args=($(_forgit_ignore_list | nl -nrn -w4 -s' ' | FZF_DEFAULT_OPTS="$opts" fzf | awk '{print $2}')) - IFS=${old_IFS} + ${old_IFS+"false"} && unset IFS || IFS="$old_IFS" [ ${#args[@]} -eq 0 ] && return 1 # shellcheck disable=SC2068 _forgit_ignore_get ${args[@]}