From: Ewan Mellor Subject: Re: [PATCH] [TESTSUITE] virtual TPM test Date: Wed, 22 Feb 2006 17:05:31 +0000 Message-ID: <20060222170531.GR28961@leeni.uk.xensource.com> References: <20060222154033.GL28961@leeni.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Stefan Berger Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org On Wed, Feb 22, 2006 at 11:48:18AM -0500, Stefan Berger wrote: > > > Index: xen/xen-unstable.hg/tools/examples/vtpm-common.sh > > > =================================================================== > > > @@ -82,16 +85,15 @@ function find_instance () { > > > if [ "$instance" != "" ]; then > > > ret=1 > > > fi > > > - return $ret > > > + res=$ret > > > } > > > > Why have you made this change? Setting a global variable to return a > result > > as a side effect is poor style. This occurs a number of times in your > patch. > > To get rid of the 'set +e' command I cannot return a number in the return > statement, otherwise the script just terminates. Got you. I prefer foo() { echo '1' } ... thing=$(foo "$param1") That way you avoid the global variable, but can still return useful things from the function. With this, you can even have more descriptive return values than integer codes, too. Cheers, Ewan.