From owner-freebsd-stable@FreeBSD.ORG Sun Jul 19 20:48:17 2009 Return-Path: Delivered-To: stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7907B1065687 for ; Sun, 19 Jul 2009 20:48:17 +0000 (UTC) (envelope-from glen.j.barber@gmail.com) Received: from mail-bw0-f208.google.com (mail-bw0-f208.google.com [209.85.218.208]) by mx1.freebsd.org (Postfix) with ESMTP id 044B98FC17 for ; Sun, 19 Jul 2009 20:48:16 +0000 (UTC) (envelope-from glen.j.barber@gmail.com) Received: by bwz4 with SMTP id 4so1462915bwz.43 for ; Sun, 19 Jul 2009 13:48:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=nNKuzxTG0+Brpz9Yjo+zpfNNrU73gVjn5gvZFVcinlk=; b=iDRtiCliGG0YrO93EIovj0+PTebcm0LHvU9VlFRAZ+1UJtE1hfzAK+XBLuCgrFqGho B+yV0rABN4MNwFlnw+Wcu4H2t64fH1KAMDLndGxE/uTASwL8B89eMpdWIv9AVcYTyecC m3A5VFp11hxC5ZUpDuieZhRxSI8naF1MQ8H5U= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=KNWp3ChHOW48oPfYMde3mQ2PUY4OQB+R2PvN7//tXegL7xABUzz/uQnlSNc/zLyYOt 1b+E25MOGCp6J69yk2aL2hFZZec5OeUWS+NJ3A3UG80W+zCA0Jq82gQ4HUJCoD5kIswX StniL+DmWNysCJLxb9o2Usbceb3sQJ51bGicI= MIME-Version: 1.0 Received: by 10.223.105.7 with SMTP id r7mr966899fao.8.1248036495822; Sun, 19 Jul 2009 13:48:15 -0700 (PDT) In-Reply-To: <20090719204458.GD85228@blogreen.org> References: <20090719202638.GA85228@blogreen.org> <4ad871310907191332r2f933a33l36c121903bc0742f@mail.gmail.com> <20090719204458.GD85228@blogreen.org> Date: Sun, 19 Jul 2009 16:48:15 -0400 Message-ID: <4ad871310907191348n6f43cffpaf391990b35b9c19@mail.gmail.com> From: Glen Barber To: =?ISO-8859-1?Q?Romain_Tarti=E8re?= Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: stable@freebsd.org Subject: Re: Value of $? lost in the beginning of a function. X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Jul 2009 20:48:17 -0000 2009/7/19 Romain Tarti=E8re : > Hi Glen, > > On Sun, Jul 19, 2009 at 04:32:28PM -0400, Glen Barber wrote: >> > % sh foo.sh >> > % zsh foo.sh >> > % bash foo.sh >> What happens if you replace '#!/bin/sh' with '#!/usr/local/bin/zsh' ? > > This is not related to my problem since I am not running the script > using ./foo.sh but directly using the proper shell. =A0sh just behaves > differently, that looks odd so I would like to know if it is a bug in sh > or if there is no specification for this and the behaviour depends of > the implementation of each shell, in which case I have to tweak the > script I am porting to avoid this construct (passing $? as an argument > for example). > > Romain > My understanding was this: If you specify 'sh foo.sh' at the shell, the script will be run in a /bin/sh shell, _unless_ you override the shell _in_ the script. Ie, 'sh foo.sh' containing '#!/bin/sh' being redundant, but 'zsh foo.sh' containing '#!/bin/sh' would execute using zsh. --=20 Glen Barber