Make: Bad Substitution

Hi,
I have a make file which I try to execute, but it failed when it arrived to the line:
for r in ${PIPESTATUS
[*]}; do if (($r != 0)); then exit $r; fi;done;
With the Error:
""make:/bin/sh: Bad substitution""
Or the Error:
"make:${PIPESTATUS[...}: Bad substitution"
(Depend on the operating system).

Can anyone help me with that?

Thanks.

Did this script work in the past or is it a totally new script ?

I assume that there is a problem with the shell. `${PIPESTATUS[*]}' is actually an aray - a functionality which isn't supported by all the shells. So it might work in one shell, but don't work in others. Here is a proof:

sidorenko@sidorenko>
>echo $0
bash

sidorenko@sidorenko>
>echo ${PIPESTATUS[*]}
0

sidorenko@sidorenko>
>/bin/sh -c 'echo ${PIPESTATUS[*]}'
sh: Syntax error: Bad substitution

you can reset the shell in your Makefile by putting:

SHELL:=/bin/bash

if you are using GNU Make.

PS: My guru has also developed a means for checking exit status of pipes which is portable to all the shells and all the Unix-platform. If you are interested you might have a look at `http://sf.net/projects/pipestatus'. That's a shell library by sourcing which you could get access to several highly portable shell functions for handling pipes, like `runpipe', `checkpipe' etc.

Setting the SHELL variable, works.