[RFT/RFA] bashjar patch
Ralf Wildenhues
Ralf.Wildenhues@gmx.de
Wed May 3 15:59:00 GMT 2006
* Ralf Wildenhues wrote on Tue, May 02, 2006 at 09:20:44PM CEST:
> * Paolo Bonzini wrote on Fri, Apr 28, 2006 at 11:31:01PM CEST:
> >
> > + trap 'rm -rf $JARTMP' EXIT
>
> I think EXIT is not portable, but 0 is. Since with mktemp you'll still
> need a trap or similar cleanup mechanism, and the exit status of the
> script matters, you'll need to change all instances "exit N" to
> (exit N); exit N
>
> (like AS_EXIT) to portably set the exit status. Otherwise, e.g. on some
> HP-UX you may falsely get a zero exit status.
>
> Also, although this may be wrongly-guided or just plain FUD, I'd always
> rather write
> test -n "$JARTMP" && rm -rf "$JARTMP"
>
> for safety.
Forgot one thing here: you want to actually carry the exit status
through the trap, and re-set it at the end. Thus, with above comments,
the code would end up like this:
trap 'exit_status=$?
if test -n "$JARTMP"; then rm -rf "$JARTMP"; fi
exit $exit_status' 0
(Thanks to a couple of subtle shell bugs, be sure not to use the
variable $status, and don't precede the setting of $exit_status with a
newline at the start of the trap code.)
Cheers,
Ralf
More information about the Gcc-patches
mailing list