Date: Tue, 22 Mar 2011 12:32:43 +0000 From: RW <rwmaillists@googlemail.com> To: freebsd-questions@freebsd.org Subject: Re: Shell script termination with exit function in backquotes Message-ID: <20110322123243.1257e695@gumby.homeunix.com> In-Reply-To: <EFA32C5B-1892-41C3-B34B-F96E75CA72CA@vicor.com> References: <AANLkTi=-CFmxRicGcosvzhBbM3DMjbWwQNirMrJ1_KP=@mail.gmail.com> <759A467E-407A-4DB8-9756-08011B5405F0@vicor.com> <AANLkTi=CXLFUBhnY1LuhkeUiGHHGZ43yd%2BMYE9L50_O4@mail.gmail.com> <AANLkTimrnV2rJLyc3M4e3gGy_GUDLXp128f6n8svM3_g@mail.gmail.com> <AANLkTim0GvnAyK3%2B=Bd1Sr=maz0B3Ybgve_c6FKWwfNs@mail.gmail.com> <AANLkTimWxiRQNG3Um__kY-6%2BQ59g5yZT-Kt0qLAqTWOO@mail.gmail.com> <EFA32C5B-1892-41C3-B34B-F96E75CA72CA@vicor.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 19 Mar 2011 09:44:57 -0700
Devin Teske <dteske@vicor.com> wrote:
> At least two variations to the rule that { ... } is a block of
> commands executed in the current shell are:
>
> 1. When the block appears as a function
Is that correct? I'd assumed that functions do execute in the current
shell since you can alter variables from a function, whilst you can't
from a "()".
e.g.
--------------------------------------------------------------------
$ cat /tmp/foo
#!/bin/sh
f (){
x=2
}
x=1
f
echo $x
( x=3 )
echo $x
--------------------------------------------------------------------
$ /tmp/foo
2
2
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110322123243.1257e695>
