zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Peter Stephenson <p.w.stephenson@ntlworld.com>
Cc: Patrick Reader <zsh578@pxeger.com>,
	"zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: Bug with assignments in some commands
Date: Mon, 18 Jan 2021 09:40:04 -0800	[thread overview]
Message-ID: <CAH+w=7br09XHfrscqrYCxuLEoX08Ju0-yOFXfUPgiYSZ7UYV4A@mail.gmail.com> (raw)
In-Reply-To: <1219668732.3070481.1610987664058@mail2.virginmedia.com>

To expand on what PWS wrote:

echo "$((x++)), x is $x" | cat
echo "${x::=2}, x is $x" | cat

Those are both obvious subshells, forked to the left.  POSIX actually
says that ALL commands in a pipeline are to be subshells, but allows
exceptions.

cat <<<"$((x++))"
cat <<END
$((x++)), x is $x
END

Those should also be obvious, "cat" is an external command so the
entire thing (including the here-document input) is forked off.

<<<"$((x++)), x is $x"
<<END
$((x++)), x is $x
END

Those are less obvious, but they are equivalent to

$NULLCMD <<<"$((x++)), x is $x"
$NULLCMD <<END
$((x++)), x is $x
END

which are again forked as separate processes.


      reply	other threads:[~2021-01-18 17:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-18 15:32 Patrick Reader
2021-01-18 16:34 ` Peter Stephenson
2021-01-18 17:40   ` 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=7br09XHfrscqrYCxuLEoX08Ju0-yOFXfUPgiYSZ7UYV4A@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=p.w.stephenson@ntlworld.com \
    --cc=zsh-workers@zsh.org \
    --cc=zsh578@pxeger.com \
    /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).