From: Michał Górny Date: Wed, 21 Sep 2011 21:46:49 +0000 (+0000) Subject: Introduce in_iuse() for IUSE checks. X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=415aaebf0027a36162e21c23efd19c62c04dfaa6;p=gentoo.git Introduce in_iuse() for IUSE checks. Such checks are used at least in autotools-utils & kde* eclasses, and are done wrong there. Thus, I've created a little reusable snippet suitable for eutils. --- diff --git a/eclass/eutils.eclass b/eclass/eutils.eclass index cd1f9ff17cec..d202031b8f98 100644 --- a/eclass/eutils.eclass +++ b/eclass/eutils.eclass @@ -1,6 +1,6 @@ # Copyright 1999-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.363 2011/09/12 20:44:01 mgorny Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.364 2011/09/21 21:46:49 mgorny Exp $ # @ECLASS: eutils.eclass # @MAINTAINER: @@ -2028,3 +2028,20 @@ path_exists() { -o) return $(( r == $# )) ;; esac } + +# @FUNCTION: in_iuse +# @USAGE: +# @DESCRIPTION: +# Determines whether the given flag is in IUSE. Strips IUSE default prefixes +# as necessary. +# +# Note that this function should not be used in the global scope. +in_iuse() { + debug-print-function ${FUNCNAME} "${@}" + [[ ${#} -eq 1 ]] || die "Invalid args to ${FUNCNAME}()" + + local flag=${1} + local liuse=( ${IUSE} ) + + has "${flag}" "${liuse[@]#[+-]}" +}