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

Re: view onto command pipeline?

On Wed, Jul 20, 2022, at 9:35 PM, Lawrence Velázquez wrote:
> 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.)

Yes indeed!  Though recall the context here was a *fixed* *literal* array:
    opts=(-c color.ui=always)
    command git $opts "$@"

Quoting "$@" agreed, but writing "${opts[@]}" instead here seems
a little bit like self-flagellation, no?

> 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.

Oh, interesting!  why is that?  Certainly want to get the most
stable state. I do vaguely remember tricky corner cases being discussed
on zsh-workers maybe decades ago, but it seems to work great now.
And, unless I picked up this autoload idiom from the mailing list,
I think it's from the man pages somewhere.   If you're advising that
it's sub-optimal, should it be removed or caveated in the documentation?

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