use of 'testing' function from testsuite/testing.sh

Paul Smith paul at mad-scientist.us
Fri May 2 23:27:11 UTC 2008


On Sat, 2008-05-03 at 01:20 +0200, Denys Vlasenko wrote:
> "echo FOO | { thing being tested; read foo; }; echo $foo"
> 
> If $foo is not set to FOO, thing ate FOO. Bad thing, bad.

This won't work in most POSIX shells.  In most shells, every part of a
pipeline is invoked in a subshell, which means $foo won't be set.  ksh
has a special feature where the final command in a pipeline is run in
the parent shell; it would work there.  But, not in bash/dash/ash/etc.

Plus, if the thing DID eat FOO, then the read will never return and your
test will hang.



More information about the busybox mailing list