zsh-users
 help / color / mirror / code / Atom feed
* is '&' the right way to do this?
@ 2019-12-17 12:33 TJ Luoma
  2019-12-18  4:38 ` dana
  0 siblings, 1 reply; 2+ messages in thread
From: TJ Luoma @ 2019-12-17 12:33 UTC (permalink / raw)
  To: Zsh MailingList

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-12-18  4:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-17 12:33 is '&' the right way to do this? TJ Luoma
2019-12-18  4:38 ` dana

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