PATCH: fix bogus "unset" abort in /bin/sh (been pending for TWO
YEARS)
Matthias Andree
ma at dt.e-technik.uni-dortmund.de
Mon Sep 20 12:11:46 PDT 2004
[WARNING: Reply-To and Mail-Followup-To set to funnel the discussion.]
Greetings,
FreeBSD's /bin/sh has a long-standing bug that causes premature abort of
a script when set -e is set and a nonexistant variable is unset.
This violates IEEE Std 1003.1 and harms portability of scripts to FreeBSD.
http://www.opengroup.org/onlinepubs/009695399/utilities/unset.html
Either test of these must print "good" else the shell is b0rked:
/bin/sh -c 'set -e ; BONK= ; unset BONK ; unset BONK ; echo good'
/bin/sh -c 'set -e ; f() { :; } ; unset -f f ; unset -f f ; echo good'
After merging the patch below and MFC'ing, please close standards/45738.
This patch (against 5.3-BETA) fixes the problems for me (yes I know it
is not very helpful without more context but I can't paste half the
files here for the mailing list):
--- src/bin/sh/exec.c.orig Thu Apr 15 05:08:30 2004
+++ src/bin/sh/exec.c Sat Sep 18 13:16:34 2004
@@ -701,7 +701,7 @@
delete_cmd_entry();
return (0);
}
- return (1);
+ return (0);
}
/*
--- src/bin/sh/var.c.orig Thu Apr 15 05:08:31 2004
+++ src/bin/sh/var.c Sat Sep 18 13:16:34 2004
@@ -761,7 +761,7 @@
}
}
- return (1);
+ return (0);
}
--
Matthias Andree
Encrypted mail welcome: my GnuPG key ID is 0x052E7D95 (PGP/MIME preferred)
More information about the freebsd-standards
mailing list