From owner-freebsd-questions@FreeBSD.ORG Mon Mar 14 22:40:30 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1DC351065673 for ; Mon, 14 Mar 2011 22:40:30 +0000 (UTC) (envelope-from 839273@gmail.com) Received: from mail-gy0-f182.google.com (mail-gy0-f182.google.com [209.85.160.182]) by mx1.freebsd.org (Postfix) with ESMTP id C65B38FC15 for ; Mon, 14 Mar 2011 22:40:29 +0000 (UTC) Received: by gyg13 with SMTP id 13so1969gyg.13 for ; Mon, 14 Mar 2011 15:40:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:reply-to:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type:content-transfer-encoding; bh=6hOv7RVCfQGVCDqXkDKZ8fvgmC9HNTMyAd/5acQGaOc=; b=bDffqfwB7TwIjXFNbhS8oWrkPuoqTwOeL0jHQZzLzcTCJwpuu+nZmaAsM4epy15bKy iFje+ZiYpfBXG9h+ya3qHAZiIAb+XRlJaY2AeN5bkQuIlu9DIwnEYEwnOeZGT1K4J5it WPZKCzXTy3rZf+WL2Vil2YXb732QjkuHmkc1k= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:reply-to:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=bC2Qb5bxIl1Kwfl9/rfxxD1rCN0KOOeSA5nPv4WmJATWKL9VCuat0iHpPHLsLtOnyN PRs7KB6sGjHcwkqhNJIfZUE52sATmCha+dnP8hBDPvG3keffFpaapIWuyPAx2JvMHT/V 4Xszw3TF6grGkW8SILUmMzcOUqc2QUfJ8vLOA= MIME-Version: 1.0 Received: by 10.150.75.15 with SMTP id x15mr4197130yba.219.1300142428981; Mon, 14 Mar 2011 15:40:28 -0700 (PDT) Sender: 839273@gmail.com Received: by 10.150.216.2 with HTTP; Mon, 14 Mar 2011 15:40:28 -0700 (PDT) In-Reply-To: References: <759A467E-407A-4DB8-9756-08011B5405F0@vicor.com> Date: Mon, 14 Mar 2011 18:10:28 -0430 X-Google-Sender-Auth: 7Zwo7BgfHRNtWhgRxFuJR0XIUnY Message-ID: From: Andres Perera To: Maxim Khitrov Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: Devin Teske , FreeBSD Subject: Re: Shell script termination with exit function in backquotes X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: 839273@gmail.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Mar 2011 22:40:30 -0000 On Mon, Mar 14, 2011 at 7:46 AM, Maxim Khitrov wrote: > On Mon, Mar 14, 2011 at 3:16 AM, Andres Perera wrote: >> On Sun, Mar 13, 2011 at 9:49 PM, Devin Teske wrote: >>> If you make the changes that I've suggested, you'll have consistent exe= cution. The reason you're having inconsistent behavior is because Linux has= /bin/sh symbolically linked to /bin/bash while FreeBSD has a more traditio= nal shell (we'll call it bourne shell "plus"). >> >> that is misleading because command substitutions have traditionally >> invoked subshells, and freebsd sh(1)/ash is an exception, not the norm >> >> in this case, ksh and bash deviates are clearly closer to standard >> bourne behaviour >> > > Thanks for that explanation. I can understand the benefits of > optimizing away subshell execution, but that can clearly lead to > unexpected behavior. Is there some documentation on when this > optimization is utilized (i.e. the command executed without a > subshell)? Would I be correct in assuming that it is only restricted > to built-in commands that are known not to produce any output, such as > 'exit'? i would check the source, autoconf docs, and http://www.in-ulm.de/~mascheck= / netbsd has been patched to fix `exit 1`, according to the last site > > - Max >