From owner-cvs-all@FreeBSD.ORG Sun Aug 14 02:06:43 2005 Return-Path: X-Original-To: cvs-all@freebsd.org Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C8FD216A41F; Sun, 14 Aug 2005 02:06:43 +0000 (GMT) (envelope-from bob@immure.com) Received: from ylpvm29.prodigy.net (ylpvm29-ext.prodigy.net [207.115.57.60]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1B20E43D49; Sun, 14 Aug 2005 02:06:42 +0000 (GMT) (envelope-from bob@immure.com) Received: from pimout3-ext.prodigy.net (pimout3-int.prodigy.net [207.115.4.218]) by ylpvm29.prodigy.net (8.12.10 outbound/8.12.10) with ESMTP id j7E26d4u011858; Sat, 13 Aug 2005 22:06:39 -0400 X-ORBL: [66.136.206.1] Received: from maul.immure.com (adsl-66-136-206-1.dsl.austtx.swbell.net [66.136.206.1]) by pimout3-ext.prodigy.net (8.13.4 outbound domainkey aix/8.13.4) with ESMTP id j7E26eJY108582; Sat, 13 Aug 2005 22:06:41 -0400 Received: from luke.immure.com (luke.immure.com [10.1.132.3]) by maul.immure.com (8.13.3/8.12.11) with ESMTP id j7E26Z43072355; Sat, 13 Aug 2005 21:06:35 -0500 (CDT) (envelope-from bob@immure.com) Received: from luke.immure.com (localhost [127.0.0.1]) by luke.immure.com (8.13.1/8.13.1) with ESMTP id j7E26Z2e021003; Sat, 13 Aug 2005 21:06:35 -0500 (CDT) (envelope-from bob@luke.immure.com) Received: (from bob@localhost) by luke.immure.com (8.13.1/8.12.11/Submit) id j7E26Z6R021002; Sat, 13 Aug 2005 21:06:35 -0500 (CDT) (envelope-from bob) Date: Sat, 13 Aug 2005 21:06:35 -0500 From: Bob Willcox To: Colin Percival Message-ID: <20050814020635.GA19321@luke.immure.com> References: <200508132128.j7DLShWb080387@repoman.freebsd.org> <42FE6A67.6000208@freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <42FE6A67.6000208@freebsd.org> User-Agent: Mutt/1.5.9i X-immure-MailScanner-Information: Please contact the ISP for more information X-immure-MailScanner: Found to be clean X-MailScanner-From: bob@immure.com Cc: cvs-src@freebsd.org, src-committers@freebsd.org, cvs-all@freebsd.org Subject: Re: cvs commit: src/usr.sbin/portsnap/portsnap portsnap.sh X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Bob Willcox List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Aug 2005 02:06:44 -0000 On Sat, Aug 13, 2005 at 02:47:19PM -0700, Colin Percival wrote: > Colin Percival wrote: > > This bug was caused by the astonishing interaction of "return" and > > pipelines; in the following code, the "return" does not exit the > > function, but instead exits the subshell which was spawned for the last > > element of the pipeline; consequently, the output produced is "foo". > > > > foo() { > > echo bar | while read baz; do > > if [ ${baz} = "bar" ]; then > > return 1 > > fi > > done > > > > echo foo > > } > > For what it's worth, I don't know if the behaviour of our sh(1) is correct > here. IEEE 1003.1, 2004 Ed. says > > "The return utility shall cause the shell to stop executing the current function > or dot script. If the shell is not currently executing a function or dot script, > the results are unspecified." > > and I don't see any mention of not returning from a function just because we > happen to be inside a subshell. I tried this on a some different shells. Turns out that bash & pdksh behave similar to the FreeBSD shell, but with ksh93 the return exits the function. So maybe ksh93 is the only one working correctly--or it's the only one that's broke. Bob > > Colin Percival > _______________________________________________ > cvs-all@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/cvs-all > To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org" -- Bob Willcox The early bird who catches the worm works for someone bob@immure.com who comes in late and owns the worm farm. Austin, TX -- Travis McGee