Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Strange parameter visibility
- X-seq: zsh-users 21940
- From: Eric Cook <llua@xxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Strange parameter visibility
- Date: Sat, 17 Sep 2016 21:42:08 -0400
- In-reply-to: <87bmzmtmzq.fsf@alfa.kjonca>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <87bmzmtmzq.fsf@alfa.kjonca>
On 09/17/2016 02:11 PM, Kamil Jońca wrote:
>
> --8<---------------cut here---------------start------------->8---
> %(x=1; x=2 echo | echo $x ; echo $x)
> 1
> 1
> --8<---------------cut here---------------end--------------->8---
>
> but :
> --8<---------------cut here---------------start------------->8---
> %(x=1; x=2 | echo $x ; echo $x)
> 2
> 2
> --8<---------------cut here---------------end--------------->8---
>
> What there are "2"-s in second example?
> should'n "x=2" be treated as simple null command with its own
> assignement?
> KJ
>
It's a normal assignment just like the x=1. the weirdness is zsh
optimizing out a fork in the pipeline, so the scope of the
reassignment wasn't just a subshell.
Though, in the first example you put the variable into echo's
environment, the shell parameter x wasn't changed at all.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author