It seems zsh
doesn't honor globs inside variable patterns, in ${var##$pat}
parameter expansions:
$ zsh -c 'pat=/*; var=/etc/; echo "$var $pat"; echo "${var##$pat}"'
/etc/ /*
/etc/
# sh result: empty
However, if $pat
does not contain *
, zsh and sh behave similarly:
$ zsh -c 'pat=/; var=/etc/; echo "$var $pat"; echo "${var##$pat}"'
/etc/ /
etc/
# sh result: same
zsh --emulate sh
gives, of course, sh-compatible results. But if I want to stay in zsh emulation, is there any setopt
option that changes this behavior? I've looked (briefly) in the docs and I can't really find the reason for this difference.