always use [[ ... ]] and not [ ... ] in bash completions
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by a1346054 · committed by Junegunn Choi · parent ab247a1 · Browse files · 1 file·+11 added−11 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+11 added−11 removed
- other:+11 added−11 removed
Provenance
- Commit
e53b4bb- Tree
7ca18b6- Author
a1346054 <36859588+a1346054@users.noreply.github.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
ab247a1
1 file changed+11 added−11 removed
modified:shell/completion.bash+11 added-11 removed
33 unmodified lines34 # To redraw line after fzf closes (printf '\e[5n')35 bind '"\e[0n": redraw-current-line'36 37 __fzf_comprun() {38- if [ "$(type -t _fzf_comprun 2>&1)" = function ]; then38+ if [[ "$(type -t _fzf_comprun 2>&1)" = function ]]; then39 _fzf_comprun "$@"40- elif [ -n "$TMUX_PANE" ] && { [ "${FZF_TMUX:-0}" != 0 ] || [ -n "$FZF_TMUX_OPTS" ]; }; then40+ elif [[ -n "$TMUX_PANE" ]] && { [[ "${FZF_TMUX:-0}" != 0 ]] || [[ -n "$FZF_TMUX_OPTS" ]]; }; then41 shift42 fzf-tmux ${FZF_TMUX_OPTS:--d${FZF_TMUX_HEIGHT:-40%}} -- "$@"43 else44 shift94 unmodified lines139 shift140 orig_cmd="$1"141 orig_var="_fzf_orig_completion_$cmd"142 orig="${!orig_var##*#}"143- if [ -n "$orig" ] && type "$orig" > /dev/null 2>&1; then143+ if [[ -n "$orig" ]] && type "$orig" > /dev/null 2>&1; then144 $orig "$@"145- elif [ -n "$_fzf_completion_loader" ]; then145+ elif [[ -n "$_fzf_completion_loader" ]]; then146 orig_complete=$(complete -p "$orig_cmd" 2> /dev/null)147 _completion_loader "$@"148 ret=$?149 # _completion_loader may not have updated completion for the command150- if [ "$(complete -p "$orig_cmd" 2> /dev/null)" != "$orig_complete" ]; then150+ if [[ "$(complete -p "$orig_cmd" 2> /dev/null)" != "$orig_complete" ]]; then151 __fzf_orig_completion < <(complete -p "$orig_cmd" 2> /dev/null)152 if [[ "$__fzf_nospace_commands" = *" $orig_cmd "* ]]; then153 eval "${orig_complete/ -F / -o nospace -F }"154 else15 unmodified lines170 eval "base=$base"171 172 [[ $base = *"/"* ]] && dir="$base"173 while true; do174- if [ -z "$dir" ] || [ -d "$dir" ]; then174+ if [[ -z "$dir" ]] || [[ -d "$dir" ]]; then175 leftover=${base/#"$dir"}176 leftover=${leftover/#\/}177- [ -z "$dir" ] && dir='.'178- [ "$dir" != "/" ] && dir="${dir/%\//}"177+ [[ -z "$dir" ]] && dir='.'178+ [[ "$dir" != "/" ]] && dir="${dir/%\//}"179 matches=$(eval "$1 $(printf %q "$dir")" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore $FZF_DEFAULT_OPTS $FZF_COMPLETION_OPTS $2" __fzf_comprun "$4" -q "$leftover" | while read -r item; do180 printf "%q$3 " "$item"181 done)182 matches=${matches% }183 [[ -z "$3" ]] && [[ "$__fzf_nospace_commands" = *" ${COMP_WORDS[0]} "* ]] && matches="$matches "184- if [ -n "$matches" ]; then184+ if [[ -n "$matches" ]]; then185 COMPREPLY=( "$matches" )186 else187 COMPREPLY=( "$cur" )188 fi44 unmodified lines233 cur=${cur:0:${#cur}-${#trigger}}234 235 selected=$(FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore $FZF_DEFAULT_OPTS $FZF_COMPLETION_OPTS $str_arg" __fzf_comprun "${rest[0]}" "${args[@]}" -q "$cur" | $post | tr '\n' ' ')236 selected=${selected% } # Strip trailing space not to repeat "-o nospace"237- if [ -n "$selected" ]; then237+ if [[ -n "$selected" ]]; then238 COMPREPLY=("$selected")239 else240 COMPREPLY=("$cur")241 fi87 unmodified lines329 func="$2"330 opts="$3"331 orig_var="_fzf_orig_completion_${cmd//[^A-Za-z0-9_]/_}"332 orig="${!orig_var}"333- if [ -n "$orig" ]; then333+ if [[ -n "$orig" ]]; then334 printf -v def "$orig" "$func"335 eval "$def"336 else337 complete -F "$func" $opts "$cmd"44 unmodified lines