This is slightly inelegant, as the old style echo foo echo blah chmod a+x $3 doesn't work anymore; the stuff you wrote to stdout didn't end up in $3. You can rewrite it as: exec >$3 echo foo echo blah chmod a+x $3 Anyway, it's better this way, because now we can tell the difference between a zero-length $3 and a nonexistent one. A .do script can thus produce either one and we'll either delete the target or move the empty $3 to replace it, whichever is right. As a bonus, this simplifies our detection of whether you did something weird with overlapping changes to stdout and $3.
11 lines
237 B
Text
11 lines
237 B
Text
redo-ifchange config.sh
|
|
. ./config.sh
|
|
exec >$3
|
|
cat <<-EOF
|
|
redo-ifchange \$1.c
|
|
gcc -MD -MF \$3.deps.tmp -o \$3 -c \$1.c
|
|
DEPS=\$(sed -e "s/^\$3://" -e 's/\\\\//g' <\$3.deps.tmp)
|
|
rm -f \$3.deps.tmp
|
|
redo-ifchange \$DEPS
|
|
EOF
|
|
chmod +x $3
|