public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in eclass: gnat.eclass
       [not found] <E1IadhO-0004La-3v@stork.gentoo.org>
@ 2007-09-27  0:56 ` Donnie Berkholz
  2007-09-27  7:47   ` George Shapovalov
  0 siblings, 1 reply; 5+ messages in thread
From: Donnie Berkholz @ 2007-09-27  0:56 UTC (permalink / raw
  To: gentoo-dev, george

On 20:41 Wed 26 Sep     , George Shapovalov (george) wrote:
> george      07/09/26 20:41:34
> 
>   Modified:             gnat.eclass
>   Log:
>   added get_active_profile helper function

> Revision  Changes    Path
> 1.28                 eclass/gnat.eclass
> 
> file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/gnat.eclass?rev=1.28&view=markup
> plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/gnat.eclass?rev=1.28&content-type=text/plain
> diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/gnat.eclass?r1=1.27&r2=1.28

> +# Returns a name of active gnat profile. Peroroms some validity checks. No input
> +# parameters, analyzes the system setup directly.
> +get_active_profile() {
> +	# get common code and settings
> +	. ${GnatCommon} || die "failed to source gnat-common lib"
> +
> +	local profiles=( $(get_env_list) ) 
> +
> +	if [[ ${profiles[@]} == "${MARKER}*" ]]; then 
> +		exit 

I'm surprised to see exit called in a function instead of returning 
nonzero.

Thanks,
Donnie
-- 
gentoo-dev@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in eclass: gnat.eclass
  2007-09-27  0:56 ` [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in eclass: gnat.eclass Donnie Berkholz
@ 2007-09-27  7:47   ` George Shapovalov
  2007-09-27  8:33     ` Mike Frysinger
  0 siblings, 1 reply; 5+ messages in thread
From: George Shapovalov @ 2007-09-27  7:47 UTC (permalink / raw
  To: gentoo-dev

Thursday, 27. September 2007, Donnie Berkholz Ви написали:
> > +	if [[ ${profiles[@]} == "${MARKER}*" ]]; then
> > +		exit
>
> I'm surprised to see exit called in a function instead of returning
> nonzero.

This exit here indicates not a very usual but a valid situation, - no gnat 
profile has been activated yet. So, this is not an error, at least not 
always. But yes, returning a non zero also possible, though testing the 
result is not that different from testing for a non-zero string, and the 
latter is not intuitively percieved as an error :).

George 
--
gentoo-dev@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in eclass: gnat.eclass
  2007-09-27  7:47   ` George Shapovalov
@ 2007-09-27  8:33     ` Mike Frysinger
  2007-09-27  9:21       ` George Shapovalov
  0 siblings, 1 reply; 5+ messages in thread
From: Mike Frysinger @ 2007-09-27  8:33 UTC (permalink / raw
  To: gentoo-dev; +Cc: George Shapovalov

[-- Attachment #1: Type: text/plain, Size: 802 bytes --]

On Thursday 27 September 2007, George Shapovalov wrote:
> Thursday, 27. September 2007, Donnie Berkholz Ви написали:
> > > +	if [[ ${profiles[@]} == "${MARKER}*" ]]; then
> > > +		exit
> >
> > I'm surprised to see exit called in a function instead of returning
> > nonzero.
>
> This exit here indicates not a very usual but a valid situation, - no gnat
> profile has been activated yet. So, this is not an error, at least not
> always. But yes, returning a non zero also possible, though testing the
> result is not that different from testing for a non-zero string, and the
> latter is not intuitively percieved as an error :).

i think more to the point, ebuilds/eclasses should never be calling `exit`

if you want to "return an empty string", then you do `return`
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 827 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in eclass: gnat.eclass
  2007-09-27  8:33     ` Mike Frysinger
@ 2007-09-27  9:21       ` George Shapovalov
  2007-09-27 13:04         ` Mike Frysinger
  0 siblings, 1 reply; 5+ messages in thread
From: George Shapovalov @ 2007-09-27  9:21 UTC (permalink / raw
  To: gentoo-dev

Thursday, 27. September 2007, Mike Frysinger Ви написали:
> i think more to the point, ebuilds/eclasses should never be calling `exit`
>
> if you want to "return an empty string", then you do `return`
Ok, sorry, will fix.
Any pointers to some description of where each should be used? Is this 
about "the shell closing itself"? They both seem to have exactly the same 
effect in this code..

George
--
gentoo-dev@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in eclass: gnat.eclass
  2007-09-27  9:21       ` George Shapovalov
@ 2007-09-27 13:04         ` Mike Frysinger
  0 siblings, 0 replies; 5+ messages in thread
From: Mike Frysinger @ 2007-09-27 13:04 UTC (permalink / raw
  To: gentoo-dev; +Cc: George Shapovalov

[-- Attachment #1: Type: text/plain, Size: 866 bytes --]

On Thursday 27 September 2007, George Shapovalov wrote:
> Thursday, 27. September 2007, Mike Frysinger Ви написали:
> > i think more to the point, ebuilds/eclasses should never be calling
> > `exit`
> >
> > if you want to "return an empty string", then you do `return`
>
> Ok, sorry, will fix.
> Any pointers to some description of where each should be used?

how about:
exit should be used: never
;)

> Is this about "the shell closing itself"?

it's about people in the past incorrectly used `exit` instead of `die` so we'd 
prefer exit not leak back in so that new people dont inadvertently get the 
same idea

> They both seem to have exactly the same effect in this code..

i imagine the way you're using it, that is true (subshelling for output / 
piping), but considering the above, we'd really ask you go with return
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 827 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-09-27 13:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <E1IadhO-0004La-3v@stork.gentoo.org>
2007-09-27  0:56 ` [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in eclass: gnat.eclass Donnie Berkholz
2007-09-27  7:47   ` George Shapovalov
2007-09-27  8:33     ` Mike Frysinger
2007-09-27  9:21       ` George Shapovalov
2007-09-27 13:04         ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox