zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zach Riggle <zachriggle@gmail.com>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: Commenting and large pipelines
Date: Wed, 11 May 2022 23:15:35 -0700	[thread overview]
Message-ID: <CAH+w=7bio+NHv6gkg=2LEE24hOanJw=gcJhZq1GXSMucgw=u-g@mail.gmail.com> (raw)
In-Reply-To: <CAMP9c5mWOpVwTpDrrJ4JheYimwcTJRyuoWy9XDdMFJo6eQSb4w@mail.gmail.com>

In addition to what Lawrence said ...

On Tue, May 10, 2022 at 11:35 PM Zach Riggle <zachriggle@gmail.com> wrote:
>
>     3. Is the use of {} better than ()?

In most cases it won't matter.  Putting something on the left side of
a pipe in zsh already starts it in a subshell, and most such subshells
are subject to an optimization such that zsh will exec the last
command to replace the shell process.

On the right side of a pipe, however commands in { } stay in the
current shell whereas those in ( ) run in a forked subshell.

>     4. How much of a performance hit does this make, versus hand-writing a different pipeline?

It's definitely going to perform better than a pipeline built by
assigning and expanding array parameters.  Otherwise the performance
difference should be minimal.

>     5. Are there any ways to improve this?  For example, replacing 'cat' in the default case.

You're not going to do better than "cat" in that context.


      parent reply	other threads:[~2022-05-12  6:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-11  6:34 Zach Riggle
2022-05-11  7:13 ` Lawrence Velázquez
2022-05-12  6:15 ` Bart Schaefer [this message]

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='CAH+w=7bio+NHv6gkg=2LEE24hOanJw=gcJhZq1GXSMucgw=u-g@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=zachriggle@gmail.com \
    --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).