[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FreeBSD sh clears $? on empty lines in trap
From: |
Pavel Roskin |
Subject: |
FreeBSD sh clears $? on empty lines in trap |
Date: |
Sat, 28 Oct 2000 14:15:11 -0400 (EDT) |
Hello!
The shell in FreeBSD 4.0 has the following bug - $? is reset to 0 by empty
lines if the code in inside "trap".
-------------------
#! /bin/sh
trap 'false
echo $?' 0
exit
-------------------
The shell script above prints 0 on FreeBSD. This doesn't apply to the
normal code, only to the code inside the "trap" command.
The patch below fixes the testsuite on FreeBSD if GNU sed is present
(otherwise we need one more patch).
ChangeLog:
* acgeneral.m4 (_AC_INIT_PREPARE): Don't use a newline before
accessing $? - newlines in "trap" reset $? to 0 on FreeBSD 4.0.
____________________
Index: acgeneral.m4
--- acgeneral.m4 Wed Oct 25 23:40:35 2000
+++ acgeneral.m4 Sat Oct 28 13:59:18 2000
@@ -1931,8 +1931,7 @@
# When interrupted or exit'd, cleanup temporary files, and complete
# config.log.
-trap '
- exit_status=$?
+trap 'exit_status=$?
test "$ac_signal" != 0 &&
echo "configure: caught signal $ac_signal" >&AC_FD_LOG
echo "configure: exit $exit_status" >&AC_FD_LOG
____________________
Regards,
Pavel Roskin
- FreeBSD sh clears $? on empty lines in trap,
Pavel Roskin <=