From owner-cvs-src@FreeBSD.ORG Sat Aug 13 21:53:24 2005 Return-Path: X-Original-To: cvs-src@FreeBSD.org Delivered-To: cvs-src@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0FAF516A41F; Sat, 13 Aug 2005 21:53:24 +0000 (GMT) (envelope-from cperciva@freebsd.org) Received: from pd2mo2so.prod.shaw.ca (shawidc-mo1.cg.shawcable.net [24.71.223.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8A87743D46; Sat, 13 Aug 2005 21:53:23 +0000 (GMT) (envelope-from cperciva@freebsd.org) Received: from pd3mr7so.prod.shaw.ca (pd3mr7so-qfe3.prod.shaw.ca [10.0.141.23]) by l-daemon (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with ESMTP id <0IL600E4RKIW1Y80@l-daemon>; Sat, 13 Aug 2005 15:47:20 -0600 (MDT) Received: from pn2ml9so.prod.shaw.ca ([10.0.121.7]) by pd3mr7so.prod.shaw.ca (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with ESMTP id <0IL600JW1KIW00A0@pd3mr7so.prod.shaw.ca>; Sat, 13 Aug 2005 15:47:20 -0600 (MDT) Received: from [192.168.0.60] (S0106006067227a4a.vc.shawcable.net [24.87.209.6]) by l-daemon (iPlanet Messaging Server 5.2 HotFix 1.18 (built Jul 28 2003)) with ESMTP id <0IL600H20KIVBB@l-daemon>; Sat, 13 Aug 2005 15:47:20 -0600 (MDT) Date: Sat, 13 Aug 2005 14:47:19 -0700 From: Colin Percival In-reply-to: <200508132128.j7DLShWb080387@repoman.freebsd.org> To: Colin Percival Message-id: <42FE6A67.6000208@freebsd.org> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1 Content-transfer-encoding: 7bit X-Accept-Language: en-us, en References: <200508132128.j7DLShWb080387@repoman.freebsd.org> User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050724) 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-src@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Aug 2005 21:53:24 -0000 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. Colin Percival