From owner-freebsd-stable@FreeBSD.ORG Mon Jul 20 01:08:05 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 6B30E1065672 for ; Mon, 20 Jul 2009 01:08:05 +0000 (UTC) (envelope-from glen.j.barber@gmail.com) Received: from mail-fx0-f205.google.com (mail-fx0-f205.google.com [209.85.220.205]) by mx1.freebsd.org (Postfix) with ESMTP id EC7278FC24 for ; Mon, 20 Jul 2009 01:08:04 +0000 (UTC) (envelope-from glen.j.barber@gmail.com) Received: by fxm1 with SMTP id 1so144184fxm.43 for ; Sun, 19 Jul 2009 18:08:02 -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=Ss/unZhn27XhfJIpaPkf2PgzdiJwS9ZI3Th3n75dVJk=; b=jVv4580j3QwhQUeD9yXi05GquuKwQyzZ6Aa6k8X0ueYbugwNKSgG/1t5iMKeWkfXzb rh4KBsZ3uPipqldowUikwK/FvAUduaaH5rCs5iS5vlYflwYw4MSTBOJfK1CRb0zJEyyL PXdkUVMJxgu2XyU3jIaGVczK4kYIpnogJFgrQ= 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=kd8EGvjWwHWIzD+U5iKTyoCJmBuZ7+GMb6s+1L/TPuZrfuxY+bvd3K7fUhC9IOLlGq mEDmD8X+NC7xwT9C06tTMmiki+3yKhye2bjbyamq3W9qVRaUgcmwtss/hfYIDrHugBif WXh2vQRNBDn4ArdoW2foGdYfpIKG/Mc/43mUs= MIME-Version: 1.0 Received: by 10.223.121.208 with SMTP id i16mr1036419far.32.1248052081064; Sun, 19 Jul 2009 18:08:01 -0700 (PDT) In-Reply-To: <200907200102.n6K12h1Y048534@drugs.dv.isc.org> References: <4ad871310907191717g1ed90be7y92250f2addc38d43@mail.gmail.com> <200907200102.n6K12h1Y048534@drugs.dv.isc.org> Date: Sun, 19 Jul 2009 21:08:00 -0400 Message-ID: <4ad871310907191808g8a81107wa17799284be176a@mail.gmail.com> From: Glen Barber To: Mark Andrews Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: stable@freebsd.org Subject: Re: Shell execution ( [was] 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: Mon, 20 Jul 2009 01:08:05 -0000 On Sun, Jul 19, 2009 at 9:02 PM, Mark Andrews wrote: > > In message <4ad871310907191717g1ed90be7y92250f2addc38d43@mail.gmail.com>,= Glen > Barber writes: >> Possibly off-topic... >> >> >> 2009/7/19 Glen Barber : >> > 2009/7/19 Romain Tarti=3DE8re : >> >> 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. =3DA0sh just beha= ves >> >> 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 argumen= t >> >> 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. >> > >> > >> >> I meant to say in the last line: "'#!/bin/sh' would override the 'zsh' s= hel=3D >> l." >> >> Can someone enlighten me if I am wrong about this? >> > > "#!" is used to define the interpretor when the file is exec'd. > > perl, AFAIK, is the only interpretor that will look at what is after > the "#!" and modify it's behaviour. =A0All other a interpretors (shells) > treat "#!" as a comment. > > Some shells used to examine the executable about to be called and > looked for "#!" and invoke the correct interpretor. =A0This was how > "#!" was supported before kernels has support for "#!". =A0It was all > done in userland. > Hi, Mark. You've given me enough information to point me in the right direction on digging further into this. Thanks, and I appreciate the response! --=20 Glen Barber