From owner-freebsd-hackers@FreeBSD.ORG Mon Sep 20 19:11:46 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 51E1816A4CE; Mon, 20 Sep 2004 19:11:46 +0000 (GMT) Received: from mail.dt.e-technik.uni-dortmund.de (krusty.dt.e-technik.Uni-Dortmund.DE [129.217.163.1]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3313F43D5A; Mon, 20 Sep 2004 19:11:45 +0000 (GMT) (envelope-from ma@dt.e-technik.uni-dortmund.de) Received: from localhost (localhost [127.0.0.1])28AF13F69E; Mon, 20 Sep 2004 21:11:44 +0200 (CEST) Received: from mail.dt.e-technik.uni-dortmund.de ([127.0.0.1]) by localhost (krusty [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 30720-01-5; Mon, 20 Sep 2004 21:11:44 +0200 (CEST) Received: from m2a2.dyndns.org (p508EEE7E.dip.t-dialin.net [80.142.238.126]) D02EC3F69A; Mon, 20 Sep 2004 21:11:40 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by merlin.emma.line.org (Postfix) with ESMTP id C2BF1D1F96; Mon, 20 Sep 2004 21:11:38 +0200 (CEST) Received: from merlin.emma.line.org ([127.0.0.1]) by localhost (m2a2.dyndns.org [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 01064-03-2; Mon, 20 Sep 2004 21:11:38 +0200 (CEST) Received: by merlin.emma.line.org (Postfix, from userid 500) id 3391CC9FB3; Mon, 20 Sep 2004 21:11:38 +0200 (CEST) To: freebsd-current@freebsd.org, re@freebsd.org, freebsd-hackers@freebsd.org, freebsd-standards@freebsd.org Mail-Followup-To: freebsd-standards@freebsd.org From: Matthias Andree Date: Mon, 20 Sep 2004 21:11:38 +0200 Message-ID: User-Agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at dt.e-technik.uni-dortmund.de X-Mailman-Approved-At: Tue, 21 Sep 2004 11:53:04 +0000 Subject: PATCH: fix bogus "unset" abort in /bin/sh (been pending for TWO YEARS) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: freebsd-standards@freebsd.org List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Sep 2004 19:11:46 -0000 [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)