zsh-users
 help / color / mirror / code / Atom feed
From: Dominik Vogt <dominik.vogt@gmx.de>
To: zsh-users@zsh.org
Subject: Re: view onto command pipeline?
Date: Thu, 21 Jul 2022 07:43:08 +0100	[thread overview]
Message-ID: <Ytj1fKb5ft8kYZX9@gmx.de> (raw)
In-Reply-To: <9310fc4a-8db9-48d8-873b-c50a63f9aea5@www.fastmail.com>

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


  parent reply	other threads:[~2022-07-21  6:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-16 16:15 Anthony Heading
2022-07-16 21:30 ` Bart Schaefer
2022-07-20 11:23   ` Anthony Heading
2022-07-20 11:37     ` Dominik Vogt
2022-07-20 12:22       ` Vincent Bernat
2022-07-20 12:35         ` Dominik Vogt
2022-07-20 19:07           ` Lawrence Velázquez
2022-07-21  0:15       ` Anthony Heading
2022-07-21  1:35         ` Lawrence Velázquez
2022-07-21  2:11           ` Anthony Heading
2022-07-21  3:15             ` Lawrence Velázquez
2022-07-21  6:43             ` Dominik Vogt [this message]
2022-08-04 21:12             ` Felipe Contreras
2022-07-20 19:27     ` Phil Pennock
2022-07-21  0:18       ` Anthony Heading

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Ytj1fKb5ft8kYZX9@gmx.de \
    --to=dominik.vogt@gmx.de \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).