Date: Mon, 27 May 2013 14:58:20 -0500 From: Reid Linnemann <linnemannr@gmail.com> To: rank1seeker@gmail.com Cc: hackers@freebsd.org Subject: Re: /bin/sh => STDIN & functions, var scope messing Message-ID: <CA%2B0MdpOcz7aw03HCrbxZVt1cnWdR4shqWaEfBrQkCpPnbgXLPQ@mail.gmail.com> In-Reply-To: <20130527.194235.693.1@DOMY-PC> References: <20130527.194235.693.1@DOMY-PC>
next in thread | previous in thread | raw e-mail | index | archive | help
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.
On Mon, May 27, 2013 at 2:42 PM, <rank1seeker@gmail.com> wrote:
> 9.1-RELEASE-p3
> ---------------
> #!/bin/sh
>
> sh_f ()
> {
> global_scope_var=7463457
> }
>
> yes | sh_f
> echo "$global_scope_var"
>
> echo '
> Now without /usr/bin/yes (maybe it is STDIN issue, instead) ?!?
> '
>
> sh_f
> echo "$global_scope_var"
> ---------------
>
>
> Domagoj Smolčić
> _______________________________________________
> freebsd-hackers@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CA%2B0MdpOcz7aw03HCrbxZVt1cnWdR4shqWaEfBrQkCpPnbgXLPQ>
