Date: Thu, 6 Nov 2014 18:30:04 +0100 From: Fabian Keil <freebsd-listen@fabiankeil.de> To: Eric van Gyzen <eric@vangyzen.net> Cc: Freebsd current <freebsd-current@freebsd.org> Subject: Re: sh: "local" assignment from command loses exit status Message-ID: <74dd7d12.793ea654@fabiankeil.de> In-Reply-To: <545BADDE.5050605@vangyzen.net> References: <545BADDE.5050605@vangyzen.net>
next in thread | previous in thread | raw e-mail | index | archive | help
--Sig_/ze6QisnF52oYxMrM.n8USM2
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable
Eric van Gyzen <eric@vangyzen.net> wrote:
> In sh, if I use a single statement to declare a local variable and
> assign the output of a command to it, the exit status of that command is
> lost. For example:
>=20
> should_return_false() {
> local var1=3D`false`
> }
>=20
> The function should return non-zero, but it returns zero.
The function should return the return code of the last command.
In your example, the last command is "local".
Fabian
--Sig_/ze6QisnF52oYxMrM.n8USM2
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iEYEARECAAYFAlRbsBwACgkQBYqIVf93VJ2HogCfTGoqZbQ5MjzNxEBm07OEdWe6
LqQAn2KZOeKJPUcZ2JAW1cQQVPCK6IX6
=mvfS
-----END PGP SIGNATURE-----
--Sig_/ze6QisnF52oYxMrM.n8USM2--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?74dd7d12.793ea654>
