[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] [TESTSUITE] virtual TPM test



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.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.