zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: Patrick Reader <zsh578@pxeger.com>, zsh-workers@zsh.org
Subject: Re: Bug with assignments in some commands
Date: Mon, 18 Jan 2021 16:34:23 +0000 (GMT)	[thread overview]
Message-ID: <1219668732.3070481.1610987664058@mail2.virginmedia.com> (raw)
In-Reply-To: <0102017716203d60-ea3cd78f-867c-4f6e-b37b-583ccdb44c13-000000@eu-west-1.amazonses.com>


> On 18 January 2021 at 15:32 Patrick Reader <zsh578@pxeger.com> wrote:
> I believe I have found a bug: in arithmetic $(( )) or $[ ] and variable 
> expansions ${ } in some forms of command (pipelines, command 
> substitutions, and inside here-documents and here-strings are the cases 
> I know of so far), assignments to variables do not persist outside the 
> command, almost as if it were in a subshell.

They *are* in a subshell.  That's just how the shell works.

The only difference between zsh and other shells is that some other shells
run the left hand of a pipeline rather than the right hand of a pipeline
in the current shell (if it's shell code, of course), but that's not
something you can rely on.  There is a patch floating around for
a compatibility mode, but in native zsh mode running the right hand
of a pipeline in the current shell, and hence the other parts in
subshells, is a feature.

pws


  reply	other threads:[~2021-01-18 16:34 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 [this message]
2021-01-18 17:40   ` Bart Schaefer

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=1219668732.3070481.1610987664058@mail2.virginmedia.com \
    --to=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).