From owner-freebsd-questions@FreeBSD.ORG Fri Mar 25 09:33:45 2005 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AC2E116A4CE for ; Fri, 25 Mar 2005 09:33:45 +0000 (GMT) Received: from weller-fahy.com (pD9FFF08E.dip.t-dialin.net [217.255.240.142]) by mx1.FreeBSD.org (Postfix) with ESMTP id B2EDA43D1D for ; Fri, 25 Mar 2005 09:33:40 +0000 (GMT) (envelope-from dave-lists-freebsd-questions@weller-fahy.com) Received: (qmail 28709 invoked by uid 1001); 25 Mar 2005 09:33:30 -0000 Date: Fri, 25 Mar 2005 10:33:30 +0100 From: "David J. Weller-Fahy" To: freebsd-questions@freebsd.org Message-ID: <20050325093308.GB10950@weller-fahy.com> Mail-Followup-To: freebsd-questions@freebsd.org References: <20050323193626.GH7474@weller-fahy.com> <20050323193716.GI7474@weller-fahy.com> <4241EDB9.5000107@toldme.com> <20050323223723.GC75716@weller-fahy.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050323223723.GC75716@weller-fahy.com> X-URL-Me: http://weller-fahy.com X-Accept-Language: en X-Location: Germany, Gangelt, Hof Grootfeld User-Agent: Mutt/1.5.9i Subject: Re: Scripting oddness (sh) - SOLVED (kind of) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Mar 2005 09:33:45 -0000 After some experimenting I believe that I've discovered how to fix the problem, and the reason for it - I'd been thinking of the '&&' shortcut as functionally identical to the if-then-fi construct. That's obviously (now ;) not the case. If, as in the previous message, the following '&&' shortcut is used: #v+ [ -z "$RB_TEMP" ] && PKGLIST="$PKGLIST $PKG" #v- Then, if RB_TEMP is not of zero length, the exit status of that command is one. Since that command is the last performed in the list_required_by function, the exit status of the function is one. Because I used 'set -e' at the top of the script, any command (a function being a complex command) that exits with a value of one halts the execution of the script. However, if we change that line to: #v+ if [ -z "$RB_TEMP" ] ; then PKGLIST="$PKGLIST $PKG" fi #v- Then, following the fi, the exit status is zero for both the command and the function, and all following commands are executed. The following also works: #v+ [ ! -z "$RB_TEMP" ] || PKGLIST="$PKGLIST $PKG" #v- Because the exit status of the first command on the line is zero if RB_TEMP is not zero length. So, there's a fix for it. Figured I'd post this FTR, just in case someone else has a lack of brain bytes similar to mine. ;] Regards, -- dave [ please don't CC me ]