Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Jul 2009 16:48:15 -0400
From:      Glen Barber <glen.j.barber@gmail.com>
To:        =?ISO-8859-1?Q?Romain_Tarti=E8re?= <romain@blogreen.org>
Cc:        stable@freebsd.org
Subject:   Re: Value of $? lost in the beginning of a function.
Message-ID:  <4ad871310907191348n6f43cffpaf391990b35b9c19@mail.gmail.com>
In-Reply-To: <20090719204458.GD85228@blogreen.org>
References:  <20090719202638.GA85228@blogreen.org> <4ad871310907191332r2f933a33l36c121903bc0742f@mail.gmail.com> <20090719204458.GD85228@blogreen.org>

next in thread | previous in thread | raw e-mail | index | archive | help
2009/7/19 Romain Tarti=E8re <romain@blogreen.org>:
> 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4ad871310907191348n6f43cffpaf391990b35b9c19>