[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gentoo-portage-dev
Subject:    [gentoo-portage-dev] [PATCH 11/13] Add tentative EAPI6 nonfatal support to die()
From:       Michał Górny <mgorny () gentoo ! org>
Date:       2014-08-18 17:56:50
Message-ID: 1408384612-14713-12-git-send-email-mgorny () gentoo ! org
[Download RAW message or body]

Add support for die() to respect 'nonfatal' modifier if
'--respect-nonfatal' (or '-n') option is used. This allows eclasses
to create custom ebuild helpers that mimic built-in helper behavior.
---
 bin/eapi.sh               | 4 ++++
 bin/isolated-functions.sh | 7 +++++++
 2 files changed, 11 insertions(+)

diff --git a/bin/eapi.sh b/bin/eapi.sh
index 6716b1c..c650a4c 100644
--- a/bin/eapi.sh
+++ b/bin/eapi.sh
@@ -166,6 +166,10 @@ ___eapi_unpack_supports_absolute_paths() {
 	[[ ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend)$ ]]
 }
 
+___eapi_die_can_respect_nonfatal() {
+	[[ ! ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
+}
+
 # OTHERS
 
 ___eapi_enables_failglob_in_global_scope() {
diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index d41f0b3..f9bc90d 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -116,6 +116,13 @@ __helpers_die() {
 die() {
 	local IFS=$' \t\n'
 
+	if ___eapi_die_can_respect_nonfatal; then
+		if [[ ${1} == -n || ${1} == --respect-nonfatal ]]; then
+			[[ ${PORTAGE_NONFATAL} == 1 ]] && return 1
+			shift
+		fi
+	fi
+
 	set +e
 	if [ -n "${QA_INTERCEPTORS}" ] ; then
 		# die was called from inside inherit. We need to clean up
-- 
2.0.4



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic