Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug on parameter expansion when set -u is in effect



I don't have a Monterey system on which to reproduce your exact environment, but with 5.8.1 freshly built from the git tag (albeit running on Tahoe), I can confirm what Mikael and Peter said: your snippet sets v to "a b" without extendedglob, and "b" with extendedglob, irrespective of nounset. 

So something else is going on in your environment. If this is the /bin/zsh shipped by Apple it might have a bug introduced by their build process?

I would just install the latest version available via Homebrew and run that instead of the one in /bin.

Mark J. Reed <markjreed@xxxxxxxxx>


On Thu, Feb 5, 2026 at 09:11 Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote:
> On 05/02/2026 13:31 GMT Ronald Fischer <ynnor@xxxxx> wrote: Actually,
> extendedglob is not needed, because the ' #' is inside the parameter
> expansion braces, and in this context, extendedglob is implicitly
> assumed - independent of the shell settings.

That's not correct, as this simpler example starting from zsh -f shows.

% var="one two"
% print ${var##one #}
one two
% setopt extendedglob
% print ${var##one #}
two

pws



Messages sorted by: Reverse Date, Date, Thread, Author