Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 31 May 2013 00:30:31 +0200
From:      Jilles Tjoelker <jilles@stack.nl>
To:        =?iso-8859-1?Q?V=E1clav?= Zeman <vhaisman@gmail.com>
Cc:        rank1seeker@gmail.com, Reid Linnemann <linnemannr@gmail.com>, hackers@freebsd.org
Subject:   Re: /bin/sh => STDIN & functions, var scope messing
Message-ID:  <20130530223031.GA1672@stack.nl>
In-Reply-To: <CAKw7uVjty2cJXT_QmexxKdRQyiKoHYMK1E-TjSHa5TCX1S8Bbg@mail.gmail.com>
References:  <20130527.194235.693.1@DOMY-PC> <CA%2B0MdpOcz7aw03HCrbxZVt1cnWdR4shqWaEfBrQkCpPnbgXLPQ@mail.gmail.com> <CAKw7uVjty2cJXT_QmexxKdRQyiKoHYMK1E-TjSHa5TCX1S8Bbg@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, May 28, 2013 at 11:48:47AM +0200, Václav Zeman wrote:
> On 27 May 2013 21:58, Reid Linnemann wrote:
> > from SH(1)

> > "Note that unlike some other shells, sh executes each process in a pipe-
> >      line with more than one command in a subshell environment and as a
> > child
> >      of the sh process."

> > I'm taking this to mean that redirecting to sh_f has sh_f execute in
> > a subshell in which global_scope_var changes, but the original
> > shell's copy is uncahnged.
> Curious. Which of the two behaviours is POSIXly correct?

Both. As per XCU 2.12 Shell Execution Environment, each command in a
multi-command pipeline may or may not be executed in a subshell
environment.

Behaviour different from our sh is most often encountered in the various
versions of the real Korn shell (ksh88 and ksh93), which execute the
last command in a pipeline in the current shell environment.

If things like  jobs | cat  work, that can also be explained using this
rule.

-- 
Jilles Tjoelker



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130530223031.GA1672>