public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] EAPI 3 and "nonfatal die"
@ 2009-08-21 20:56 David Leverton
  2009-08-21 21:09 ` Maciej Mrozowski
                   ` (3 more replies)
  0 siblings, 4 replies; 23+ messages in thread
From: David Leverton @ 2009-08-21 20:56 UTC (permalink / raw
  To: gentoo-dev

In EAPI 3, most commands and functions provided by the package
manager automatically call die if they fail.  There's also a
new "nonfatal" function that can be used to suppress this
behaviour: by prefixing a function/command call with nonfatal,
the automatic die behaviour is suppressed during the executation
of that function/command.

The difficulty here is that it's not clear what nonfatal should
do to explicit die and assert calls.  On the one hand, if
nonfatal does suppress these functions, then nonfatal can be
usefully used with eclass functions - silly hypothetical example:

    # eclass
    escons() {
        scons "${@}" || die "scons failed"
    }

    # ebuild
    nonfatal escons || do_something_else

On the other hand, it could be risky to change the behaviour of
existing functions like that:

    do_foo() {
        cd foo || die "cd failed"
        # something that would be dangerous if run in some other directory
    }

If called as "nonfatal do_foo" and the cd failed, do_foo
/wouldn't/ return a failure code - it would proceed with the rest
of its body and wreak all manner of havoc.

One way around this would be to add either an option to die to
explicitly tell it to respect nonfatal, or an alternative die
function.  This would allow eclasses to choose to respect
nonfatal when it's safe to do so, but without changing existing
behaviour.  The disadvantage of this is that it would require
changes to all eclass functions that could potentially use it,
plus the slight ugliness of making them handle older EAPIs as
well.

Another option would be to make die respect nonfatal by default,
and add an option that doesn't.  This wouldn't require changes to
eclasses that want the nonfatal behaviour, but it would require
some care to make sure that it was used when necessary.  A
potential advantage of this over the previous solution is that if
the "force" option is implemented with an environment variable,
it can be used regardless of EAPI - the previous example could be
changed to something like

    do_foo() {
        cd foo || DIE_FORCE=1 die "cd failed"
        # something that would be dangerous if run in some other directory
    }

Does anyone have any opinions on which of the four options (#1
make die respect nonfatal, #2 make die always die, #3 add a new
die variant that respects nonfatal, #4 make regular die respect
nonfatal, and add a new variant that doesn't) we should go with?
We should definitely get this resolved and agreed on before EAPI
3 is finalised.



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

end of thread, other threads:[~2011-10-31  3:59 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-21 20:56 [gentoo-dev] EAPI 3 and "nonfatal die" David Leverton
2009-08-21 21:09 ` Maciej Mrozowski
2009-08-21 21:12   ` Ciaran McCreesh
2009-08-21 23:01     ` Maciej Mrozowski
2009-08-21 23:06       ` Ciaran McCreesh
2009-08-21 23:20         ` Maciej Mrozowski
2009-08-21 23:26           ` Ciaran McCreesh
2009-08-21 21:34 ` [gentoo-dev] " David Leverton
2009-08-21 22:40 ` [gentoo-dev] " Arfrever Frehtes Taifersar Arahesis
2009-08-21 22:51   ` Ciaran McCreesh
2009-08-21 23:15     ` Arfrever Frehtes Taifersar Arahesis
2009-08-21 23:28       ` Ciaran McCreesh
2009-08-21 23:39         ` Arfrever Frehtes Taifersar Arahesis
2009-08-21 23:43           ` Ciaran McCreesh
2009-08-23  2:48             ` Arfrever Frehtes Taifersar Arahesis
2009-08-23 15:19               ` Ciaran McCreesh
2009-08-22  2:46 ` [gentoo-dev] " Ryan Hill
2009-08-24 18:20   ` Christian Faulhammer
2009-08-24 19:02     ` Thomas Anderson
2009-08-25 10:21     ` Marijn Schouten (hkBst)
2009-08-25 11:35       ` Ciaran McCreesh
2009-08-24 22:09   ` Zac Medico
2009-08-24 22:16     ` Ciaran McCreesh

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