In the following code I expect the while loop to execute three times, once for each matching line in the input build.cfg file. This is in fact what does happen, but only if I comment out the guts of the case blocks — i.e. the subshells starting with ( mkdir work ... and ( cd product ....
When executed as shown below, the loop executes only once (for BUILDTYPE == build)
When run with -x, it’s clear that the shell loops back and executes the read but gets EOF, as there are no errors and execution continues with the setStatus line.
Clearly, something in the subshell is interfering with the outer pipeline file descriptors. Can someone explain exactly why this is happening?
egrep "^\s*$BRANCH" $ETC/build.cfg | ( while read BRANCH TARGET SVNSRC SVNTAG BUILDTYPE DISTTYPE DISTARGS
do
echo ----- $TARGET $BUILDTYPE
pushd $WORKSPACE/$BUILDUID
case $BUILDTYPE in
build)
echo ">>> BUILD"
( mkdir work
cp product/buildcontrol/buildConfig_example.xml work/defaultBuildConfig.xml
cd product
./build installer-all )
;;
tma)
echo ">>> TMA"
( cd product
./build -f ..${SVNTAG}build.xml )
;;
*)
;;
esac
popd
done )
setStatus 3
Some command should be reading from stdin. Try running the commands inside the loop with stdin redirected: