From owner-freebsd-hackers@FreeBSD.ORG Fri May 31 20:05:53 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 DD7FD580 for ; Fri, 31 May 2013 20:05:53 +0000 (UTC) (envelope-from utisoft@gmail.com) Received: from mail-ie0-x232.google.com (mail-ie0-x232.google.com [IPv6:2607:f8b0:4001:c03::232]) by mx1.freebsd.org (Postfix) with ESMTP id AFF42A27 for ; Fri, 31 May 2013 20:05:53 +0000 (UTC) Received: by mail-ie0-f178.google.com with SMTP id f4so5123245iea.37 for ; Fri, 31 May 2013 13:05:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=0A/Uc9ikeXJu3fv2TB0IaVKs1hc3i0Cjtnu6Hww//G8=; b=oPjpOKpk2TVja1Unk0kobYR1hlkpCy9+Y3AHjyYkdzt7xqbEBK6TI8XwoJqwYXGdMg irVkH0RxQg6XkxFTSYXP/qKZNSUuSz9msM61RPHgOLOiE0AQHuzlIq9VFIW5p7mQ6v4+ I0HDTotcb6Vc8ZyhMeF7RQsIFXOwv3CCD6XuzbDJdXa/Xn3MXj0ZFCr/bV/nQeix9wlP XKd1gqYBh6Hja2jgJ4PEz+gbAevt2gX5bjUpWz2GQPuDVolD/yMGH9TYP4XYVyCUzLDJ ORk2GI0HT/2Ivd9zul7/NDYX3QRfd0oVRnL14DkQ53iOpAO4S8NdgN+kkuuVyqQIh942 VZoA== MIME-Version: 1.0 X-Received: by 10.50.118.69 with SMTP id kk5mr2410883igb.36.1370030753456; Fri, 31 May 2013 13:05:53 -0700 (PDT) Received: by 10.64.71.101 with HTTP; Fri, 31 May 2013 13:05:53 -0700 (PDT) Received: by 10.64.71.101 with HTTP; Fri, 31 May 2013 13:05:53 -0700 (PDT) In-Reply-To: <20130531194703.GC5410@dan.emsphone.com> References: <20130527.194235.693.1@DOMY-PC> <20130530223031.GA1672@stack.nl> <20130531.175959.745.2@DOMY-PC> <13CA24D6AB415D428143D44749F57D7201F6AD11@ltcfiswmsgmb21> <20130531194703.GC5410@dan.emsphone.com> Date: Fri, 31 May 2013 21:05:53 +0100 Message-ID: Subject: Re: /bin/sh => STDIN & functions, var scope messing From: Chris Rees To: Dan Nelson Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: rank1seeker@gmail.com, Reid Linnemann , 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 20:05:53 -0000 On 31 May 2013 20:50, "Dan Nelson" wrote: > > 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. Right... But it's not portable. Chris