From: Philip Reynolds (phil at domain redbrick.dcu.ie)
Date: Thu 20 Jul 2000 - 14:03:39 IST
McLoughlin, Mark's [mark.mcloughlin at domain intel.com] 97 lines of dribble included:
:>Bash seems to have weird rules about when to export variables out of a loop
:>or there's a bug. Either way it's interesting. Sorry the mail is so long ;)
:>
:>Incidently this doesn't happen with ksh.
<chop code>
Bash executes each command of a pipeline in a subshell.
So things like
echo "Why will this not work?" | read var
won't work.
#!/bin/bash
export VAR="joe"
VAR=$(
cat test | while read blah
do
echo $blah
done
)
echo $VAR
That's the work around
Phil.
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:06:56 GMT