zsh-users
 help / color / mirror / code / Atom feed
From: TJ Luoma <luomat@gmail.com>
To: Zsh MailingList <zsh-users@zsh.org>
Subject: is '&' the right way to do this?
Date: Tue, 17 Dec 2019 07:33:41 -0500	[thread overview]
Message-ID: <CADjGqHsi7uGmSfXaty8bWo9j4+Daa5tdEzvv2qKAgnMjNcowKg@mail.gmail.com> (raw)

Every now and again I realize that I've developed a habit, but it
isn't the "right" or "best" way to do something, so I'm asking what
may be an obvious question.

If I am in a zsh shell script (not interactive) and want to have it do
something tangential which does not block the progress of the
main/parent script, then I usually put it in (parentheses) with a & at
the end of the line

So, to use a dramatic example:

#!/bin/zsh -f

echo "This is the start"

( find / -type f -print > /tmp/filelist.txt ) &

echo "This is the end"

exit 0

My intention is that the script would exit long before `find` was done
writing to  '/tmp/filelist.txt'.

Question #1:  Would it be better for any reason to use `&|` such as:

#!/bin/zsh -f

echo "This is the start"

( find / -type f -print > /tmp/filelist.txt ) &|

echo "This is the end"

exit 0

or is the use of `&|` really only beneficial for interactive shells?


Question #2: Are there better ways of doing this?


Thanks!

TjL

             reply	other threads:[~2019-12-17 12:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-17 12:33 TJ Luoma [this message]
2019-12-18  4:38 ` dana

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=CADjGqHsi7uGmSfXaty8bWo9j4+Daa5tdEzvv2qKAgnMjNcowKg@mail.gmail.com \
    --to=luomat@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).