mrjohannchang / zsh-interactive-cd

Fish like interactive tab completion for cd in zsh
Mozilla Public License 2.0
314 stars 37 forks source link

Fix command not found error #15

Closed mike182uk closed 3 years ago

mike182uk commented 3 years ago

Hey 👋

I upgraded recently and noticed i was getting the following error:

__zic_fzf_bindings:4: command not found: fzf-tmux -d50%

This would show when triggering completion (cd <TAB>)

The command would still actually work though... (I would see the tmux pane with the results)

I traced this back to the changes made here, in particular this change. Looks to be some kind of expansion issue.

cc @jrwrigh

jrwrigh commented 3 years ago

This looks good to me.

For why it works (I had to look it up, so figured I might as well document), from the zsh documentation:

${=spec} Perform word splitting using the rules for SH_WORD_SPLIT during the evaluation of spec, but regardless of whether the parameter appears in double quotes; if the ‘=’ is doubled, turn it off. This forces parameter expansions to be split into separate words before substitution, using IFS as a delimiter. This is done by default in most other shells.

Note that splitting is applied to word in the assignment forms of spec before the assignment to name is performed. This affects the result of array assignments with the A flag.

So that expansion is required if the command in the variable has $IFS delimited arguments.

Examples:

If I set test='ls':

computer% ${test} 
[outputs directories correctly]

If I set test='ls -al':

computer% ${test} 
zsh: command not found: ls -al

computer% ${=test} 
[outputs directories correctly with -al flags passed through correctly]