Commit eb5a316f authored by Russ Cox's avatar Russ Cox

make sure errchk only prints BUG once.

using a variable is not sufficient, because
sometimes bug() is called from a subshell.

R=iant
DELTA=7  (2 added, 1 deleted, 4 changed)
OCL=18092
CL=18145
parent 7112dc1d
...@@ -29,9 +29,11 @@ TMPERR=/tmp/errchk-err-$$ ...@@ -29,9 +29,11 @@ TMPERR=/tmp/errchk-err-$$
TMPALL=/tmp/errchk-all-$$ TMPALL=/tmp/errchk-all-$$
TMPTMP=/tmp/errchk-tmp-$$ TMPTMP=/tmp/errchk-tmp-$$
TMPSTAT=/tmp/errchk-stat-$$ TMPSTAT=/tmp/errchk-stat-$$
rm -f $TMPOUT $TMPERR $TMPALL $TMPTMP $TMPSTAT TMPBUG=/tmp/errchk-bug-$$
trap "rm -f $TMPOUT $TMPERR $TMPALL $TMPTMP $TMPSTAT" 0 1 2 3 14 15 rm -f $TMPOUT $TMPERR $TMPALL $TMPTMP $TMPSTAT $TMPBUG
trap "rm -f $TMPOUT $TMPERR $TMPALL $TMPTMP $TMPSTAT $TMPBUG" 0 1 2 3 14 15
if $* >$TMPOUT 2>$TMPERR; then if $* >$TMPOUT 2>$TMPERR; then
echo 1>&2 "BUG: errchk: command succeeded unexpectedly: " "$@" echo 1>&2 "BUG: errchk: command succeeded unexpectedly: " "$@"
...@@ -43,12 +45,11 @@ fi ...@@ -43,12 +45,11 @@ fi
cat $TMPOUT $TMPERR | grep -v '^ ' > $TMPALL cat $TMPOUT $TMPERR | grep -v '^ ' > $TMPALL
didbug=false
bug() { bug() {
if ! $didbug if ! test -f $TMPBUG
then then
echo 1>&2 -n BUG: '' echo 1>&2 -n BUG: ''
didbug=true echo >$TMPBUG
fi fi
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment