5

I have found the $==* idiom in several zsh solutions that I use. It seems to be equivalent to $argv. But I don't know how it gets interpreted. Could you explain?

2

This is one of Zsh's parameter expansions here applied to $*:

${=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.

See Gilles' typically thorough answer to What is word splitting? Why is it important in shell programming for context.

Normally, zsh doesn't do word splitting by default, so presumably, that's to make sure $* is not split even when the SH_WORD_SPLIT option has been enabled one way or another (for instance via a emulate sh).

However, in most cases, you'd rather want to use "$@" (note the quotes which are important here) instead of $==*. $==* (like $* when SH_WORD_SPLIT is off) expands only to the non-empty positional parameters, while "$@" expands to all the positional parameters (regardless of SH_WORD_SPLIT, and that works in all Bourne-like shells).

  • @StéphaneChazelas Thanks: that is much better... – jasonwryan Sep 11 '14 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.