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

Re: view onto command pipeline?



On Wed, Jul 20, 2022 at 10:11:45PM -0400, Anthony Heading wrote:
> 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?

No.  Who guarantees that this array is not modified later during a
potential rewrite of the function?  Of course it's stupid, but
I've seen people automate their checkins in a script with an empty
commit message.  I write production quality shell scripts with
various shells as part of my job.  People _always_ forget to quote
their variables.  Make a habit of it and you're safe.

Ciao

Dominik ^_^  ^_^

--

Dominik Vogt




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