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

Re: view onto command pipeline?

On Wed, Jul 20, 2022, at 8:15 PM, Anthony Heading wrote:
> Agree
> quoting $@ makes sense here since this is a wrapper, but I find more 
> often dropping empty
> arguments is often very helpful after splits and suchlike.
> But as to "${opts[@]}"...   Just too ugly to do that all the time, no?  
> Instead, use
> zsh's awesome sticky emulation: 
>     emulate zsh -c 'autoload -Uz ~/my-zsh-funcs/*'

Leaving $opts[@] unquoted still elides empty elements in this
context; that behavior is not limited to $@.  (If this is what you
actually want, go for it.  Just don't think that fiddling with
options has an effect.)

> Very helpful for insulating the risks of unexpected option settings, 
> and makes it
> safe to use unquoted variables.   As a rule of thumb, at least :-)

It's better to run ''emulate -L zsh'' inside the function itself
(or localize and [un]set options individually as desired) to achieve
a known state, rather than relying on a specific method of invocation.


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