Consider the following zsh function
function foobar() {
local foo=$(fzf) && echo "$foo-bar"
}
if instead of selecting one of the results of the fzf command I exit fzf without selecting anything, the second command is executed anyway and I get
-bar
on stdout. If instead I assign the variable without the local attribute the second command is only executed if I select something from fzf, which is what I want.
Since assigning variables with the local attribute in functions is preferable to not doing that, how can I fix that behaviour?