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

Re: Help w/compctl & ksh_glob



On Aug 18,  2:02am, Jerry A! wrote:
} Subject: Re: Help w/compctl & ksh_glob
}
} : The documentation for 'compctl -g' may have part of the answer:
} : 
} :      [...]  More than one pattern may be
} :      given separated by blanks. (Note that brace expansion is _not_
} :      part of globbing.  Use the syntax `(either|or)' to match
} :      alternatives.)
} 
} Actually, {} globbing is valid ksh93 syntax.  It's not valid ksh88
} syntax.  But I've always pictured zsh's ksh emulation as ksh93
} emulation.

It's valid syntax, but it's not _globbing_ syntax.  The meaning of
	*.+(b{oo,ar,az}|quu|txt)
is to expand the expression to the three words
	*.+(boo|quu|txt) *.+(bar|quu|txt) *.+(baz|quu|txt)
Only _after_ that expansion has occured does globbing apply.

You can see why that must be the case if you consider an expression
	*.+(b{oo,a/r,/az}|quu|txt)
which probably results in two invalid glob patterns (it does in zsh,
at least, because alternatives within (|) can't cross directories), but
one pattern which still produces matches.  If brace expansion were part
of globbing, the entire expression would be invalid.

In the case of 'compctl -g', globbing is applied directly to the string
without first performing brace expansion, so you must use an additional
layer of (|).

} : However, the real problem is something to do with the SH_GLOB option,
} 
} This got the wheel's turning.  Turn's out that 'emulate ksh' turns on
} 'SH_GLOB', which in turns disables (|) globbing.

That's not precisely what's happening, because as I said the (|) pattern
works as expected when it's used on the command line (or at least, it
does for me); it fails only in the compctl arguments.  I haven't been
able to figure out why yet.



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