From owner-freebsd-hackers@FreeBSD.ORG Fri May 31 19:50:01 2013 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 5E1A2FA4 for ; Fri, 31 May 2013 19:50:01 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from email2.allantgroup.com (email2.emsphone.com [199.67.51.116]) by mx1.freebsd.org (Postfix) with ESMTP id 0C932975 for ; Fri, 31 May 2013 19:50:00 +0000 (UTC) Received: from dan.emsphone.com (dan.emsphone.com [172.17.17.101]) by email2.allantgroup.com (8.14.5/8.14.5) with ESMTP id r4VJl4Np064343 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 31 May 2013 14:47:04 -0500 (CDT) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (smmsp@localhost [127.0.0.1]) by dan.emsphone.com (8.14.7/8.14.6) with ESMTP id r4VJl3ea015331 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 31 May 2013 14:47:03 -0500 (CDT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.14.7/8.14.6/Submit) id r4VJl3tt015330; Fri, 31 May 2013 14:47:03 -0500 (CDT) (envelope-from dan) Date: Fri, 31 May 2013 14:47:03 -0500 From: Dan Nelson To: Reid Linnemann Subject: Re: /bin/sh => STDIN & functions, var scope messing Message-ID: <20130531194703.GC5410@dan.emsphone.com> References: <20130527.194235.693.1@DOMY-PC> <20130530223031.GA1672@stack.nl> <20130531.175959.745.2@DOMY-PC> <13CA24D6AB415D428143D44749F57D7201F6AD11@ltcfiswmsgmb21> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-OS: FreeBSD 9.1-STABLE User-Agent: Mutt/1.5.21 (2010-09-15) X-Virus-Scanned: clamav-milter 0.97.8 at email2.allantgroup.com X-Virus-Status: Clean X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.7 (email2.allantgroup.com [172.17.19.78]); Fri, 31 May 2013 14:47:04 -0500 (CDT) X-Spam-Status: No, score=-3.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on email2.allantgroup.com X-Scanned-By: MIMEDefang 2.73 Cc: "" , FreeBSD Hackers , Jilles Tjoelker X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 May 2013 19:50:01 -0000 In the last episode (May 31), Reid Linnemann said: > On Fri, May 31, 2013 at 1:12 PM, Teske, Devin wrote: > > If you're arguing we have to change sh's behavior to be more compliant, > > jilles already quoted XCU 2.12 (our shell is well within its right to > > run any/all lvalue/rvalue operands of a pipe in a sub-shell without > > contradicting the guidelines). > > > > But if you're arguing that it has to change to make things better or > > easier... I don't know about that. Might just make people lulled into > > using a style that's non-portable. I'd like to keep things the way they > > are so that if you program for FreeBSD, you're inherently going to > > program in a fashion that is more portable. > > FWIW bash (invoked as sh) on RHEL-based linux systems exhibits the same > behavior- > > sh-3.2$ var=1 > sh-3.2$ yes|var=2 > sh-3.2$ echo $var > 1 > sh-3.2$ > > If my opinion matters at all, I would agree that for the sake of > portability that behavior be consistent with the majority of sh > implementations rather than "right" according to arbitrary ruling. On the other hand, zsh runs the last component of a pipeline in the parent shell. The usual model is "do work in pipeline, process results in final component", and being able to simply set variables there that can be used in the rest of the script is very elegant. -- Dan Nelson dnelson@allantgroup.com