From owner-freebsd-questions@FreeBSD.ORG Mon Mar 14 12:17:22 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 28261106566B for ; Mon, 14 Mar 2011 12:17:22 +0000 (UTC) (envelope-from max@mxcrypt.com) Received: from mail-vw0-f54.google.com (mail-vw0-f54.google.com [209.85.212.54]) by mx1.freebsd.org (Postfix) with ESMTP id D844A8FC0C for ; Mon, 14 Mar 2011 12:17:21 +0000 (UTC) Received: by vws18 with SMTP id 18so2604303vws.13 for ; Mon, 14 Mar 2011 05:17:21 -0700 (PDT) Received: by 10.220.180.65 with SMTP id bt1mr407634vcb.135.1300105040257; Mon, 14 Mar 2011 05:17:20 -0700 (PDT) MIME-Version: 1.0 Received: by 10.220.180.135 with HTTP; Mon, 14 Mar 2011 05:16:50 -0700 (PDT) In-Reply-To: References: <759A467E-407A-4DB8-9756-08011B5405F0@vicor.com> From: Maxim Khitrov Date: Mon, 14 Mar 2011 08:16:50 -0400 Message-ID: To: 839273@gmail.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: Devin Teske , Andres Perera , 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 List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Mar 2011 12:17:22 -0000 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 exec= ution. The reason you're having inconsistent behavior is because Linux has = /bin/sh symbolically linked to /bin/bash while FreeBSD has a more tradition= al 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'? - Max