From owner-freebsd-current@FreeBSD.ORG Thu Nov 6 17:37:01 2014 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DA54EFB2 for ; Thu, 6 Nov 2014 17:37:01 +0000 (UTC) Received: from smtprelay03.ispgateway.de (smtprelay03.ispgateway.de [80.67.31.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 97D64E7C for ; Thu, 6 Nov 2014 17:37:01 +0000 (UTC) Received: from [78.35.171.175] (helo=fabiankeil.de) by smtprelay03.ispgateway.de with esmtpsa (TLSv1.2:AES128-GCM-SHA256:128) (Exim 4.84) (envelope-from ) id 1XmQsl-0007v8-3f; Thu, 06 Nov 2014 18:30:03 +0100 Date: Thu, 6 Nov 2014 18:30:04 +0100 From: Fabian Keil To: Eric van Gyzen 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> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; boundary="Sig_/ze6QisnF52oYxMrM.n8USM2"; protocol="application/pgp-signature" X-Df-Sender: Nzc1MDY3 Cc: Freebsd current X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Nov 2014 17:37:01 -0000 --Sig_/ze6QisnF52oYxMrM.n8USM2 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Eric van Gyzen 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--