On Tue, 23 Feb 2010, t...@icada.com wrote: > Configuration Information [Automatically generated, do not change]: > Machine: x86_64 > OS: linux-gnu > Compiler: gcc -I/usr/src/packages/BUILD/bash-3.1 > -L/usr/src/packages/BUILD/bash-3.1/../readline-5.1 > Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' > -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-suse-linux-gnu' > -DCONF_VENDOR='suse' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL > -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -O2 -fmessage-length=0 -Wall > -D_FORTIFY_SOURCE=2 -g -D_GNU_SOURCE -DRECYCLES_PIDS -Wall -pipe -g -fPIE > -fbranch-probabilities > uname output: Linux t60 2.6.18.8-0.13-default #1 SMP Thu Nov 6 13:35:13 UTC > 2008 x86_64 x86_64 x86_64 GNU/Linux > Machine Type: x86_64-suse-linux-gnu > > Bash Version: 3.1 > Patch Level: 17 > Release Status: release > > Description: > I would have expected the output to be 2 in both cases. My mistake or > yours? :-) > > Repeat-By: > a=1; echo foo;{ a=2; }; echo $a # output: 2 > a=1; echo foo|{ a=2; }; echo $a # output: 1 > > Bug or feature?
Standard behaviour; all components of a pipeline are executed in a subshell. -- Chris F.A. Johnson <http://cfajohnson.com> =================================================================== Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)