Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 451938

Summary: [Future EAPI] Provide an ability to use 'nonfatal' on custom helpers
Product: Gentoo Hosted Projects Reporter: Michał Górny <mgorny>
Component: PMS/EAPIAssignee: PMS/EAPI <pms>
Status: RESOLVED FIXED    
Severity: enhancement CC: esigra
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=551152
Whiteboard: in-eapi-6
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 174380    

Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-01-13 22:54:40 UTC
In EAPI 4 all standard helpers started to 'die' by default and 'nonfatal' was provided in order to provide an ability to restore the previous behavior. However, the 'nonfatal' is worded that it does not apply to direct die or assert calls.

Therefore, custom helpers in eclasses are unable to use 'nonfatal' not to die. Although they can be made nonfatal in a custom way, I'd rather see PMS providing an unified ability, preferably within the bounds of 'nonfatal'.

One solution I see is providing an additional 'die' command which would respect nonfatal, possibly with additional restrictions on leaving the function.
Comment 1 Ulrich Müller gentoo-dev 2013-03-28 18:39:07 UTC
Could we add an option (like "-n") to "die" and "assert" that would make them respect nonfatal?

I.e., "nonfatal die" would die, but "nonfatal die -n" would not (but return unsuccessful status).
Comment 2 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-03-28 18:43:12 UTC
(In reply to comment #1)
> Could we add an option (like "-n") to "die" and "assert" that would make
> them respect nonfatal?

  die -n 'foo failed.'

looks a bit weird, to be honest. But I guess it would work. I would personally go more for something like '--weak' if it's supposed to be solve via an option.
Comment 3 Ulrich Müller gentoo-dev 2014-08-27 13:08:59 UTC
Looking at the larger picture, almost all helper functions accept short options only. The two exceptions to this are "doman -i18n" and "has_version --host-root". In both cases, long option processing is incompatible with GNU getopt (e.g., long options cannot be abbreviated).

Therefore I'd much prefer a single letter option like -c (mnemonic: "conditional"), -n ("nonfatal"), or -r ("return").
Comment 4 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2014-08-27 13:22:01 UTC
Well, the patch I submitted for review has:

  [[ ${1} == -n || ${1} == --respect-nonfatal ]]
Comment 5 Ulrich Müller gentoo-dev 2014-08-27 14:42:30 UTC
(In reply to Michał Górny from comment #4)
> Well, the patch I submitted for review has:
> 
>   [[ ${1} == -n || ${1} == --respect-nonfatal ]]

None of our functions accepts both short and long options. Unless we decide on a consistent option scheme throughout (preferably, getopt compatible), I'd rather not add yet another variant.