Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Jul 2009 22:26:38 +0200
From:      Romain =?iso-8859-1?Q?Tarti=E8re?= <romain@blogreen.org>
To:        stable@FreeBSD.org
Subject:   Value of $? lost in the beginning of a function.
Message-ID:  <20090719202638.GA85228@blogreen.org>

next in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
Hi!

Simple test case:

----8<----------------------
#!/bin/sh
foo()
{
  echo "\$?=$? \$1=$1"
}
false
foo $?
----8<----------------------

% sh foo.sh
$?=0 $1=1
% zsh foo.sh
$?=1 $1=1
% bash foo.sh
$?=1 $1=1

As you can see, the value of $? is « lost » when FreeBSD sh enters a
function.  Is this supposed to behave this way?

Thanks,
Romain

-- 
Romain Tartière <romain@blogreen.org>        http://romain.blogreen.org/
pgp: 8DAB A124 0DA4 7024 F82A  E748 D8E9 A33F FF56 FF43 (ID: 0xFF56FF43)
(plain text =non-HTML= PGP/GPG encrypted/signed e-mail much appreciated)

[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.12 (FreeBSD)

iEYEARECAAYFAkpjgX4ACgkQ2OmjP/9W/0O9QACgkZizpSZ0b1ob7W8m+GDa8+5p
js0An1LmFZ+hBCWiFe+LmVIkh1LGm2o2
=2Qr+
-----END PGP SIGNATURE-----

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