From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 308911384B4 for ; Sun, 29 Nov 2015 16:48:59 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 4792921C097; Sun, 29 Nov 2015 16:48:51 +0000 (UTC) Received: from a1www.kph.uni-mainz.de (a1www.kph.uni-mainz.de [134.93.134.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 1CFB821C012 for ; Sun, 29 Nov 2015 16:48:49 +0000 (UTC) Received: from a1i15.kph.uni-mainz.de (a1i15.kph.uni-mainz.de [134.93.134.92]) by a1www.kph.uni-mainz.de (8.14.9/8.14.7) with ESMTP id tATGmmRJ017602 for ; Sun, 29 Nov 2015 17:48:48 +0100 Received: from a1i15.kph.uni-mainz.de (localhost [127.0.0.1]) by a1i15.kph.uni-mainz.de (8.14.8/8.14.2) with ESMTP id tATGmmsq026785; Sun, 29 Nov 2015 17:48:48 +0100 Received: (from ulm@localhost) by a1i15.kph.uni-mainz.de (8.14.8/8.14.8/Submit) id tATGmlk9026781; Sun, 29 Nov 2015 17:48:47 +0100 Message-ID: <22107.11375.846871.672757@a1i15.kph.uni-mainz.de> Date: Sun, 29 Nov 2015 17:48:47 +0100 To: gentoo-dev@lists.gentoo.org Subject: [gentoo-dev] [PATCH] eutils.eclass: In EAPI conditionals, replace "has" by case statements. In-Reply-To: <22106.64938.215501.17191@a1i15.kph.uni-mainz.de> References: <22106.64938.215501.17191@a1i15.kph.uni-mainz.de> X-Mailer: VM 8.2.0b under 24.3.1 (x86_64-pc-linux-gnu) From: Ulrich Mueller Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org MIME-Version: 1.0 Content-Type: multipart/signed; boundary="pgp+signed+GNJk9+dlp3WSnIq"; micalg=pgp-sha256; protocol="application/pgp-signature" X-Archives-Salt: 4dad6dda-3a52-4372-91de-0d486f536d33 X-Archives-Hash: 850238ee25a323afbcb9bbf31f81fc4c This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --pgp+signed+GNJk9+dlp3WSnIq Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable As suggested by mgorny, we could use bash internals instead of the "has" function calls in global scope. The patch below replaces them by case statements. (Unfortunately we cannot use fall-through (&;) because it is a bash 4 feature.) Ulrich =46rom 89e837f5179354aa3dfa454f51282ad9d1143402 Mon Sep 17 00:00:00 2001 From: =3D=3FUTF-8=3Fq=3FUlrich=3D20M=3DC3=3DBCller=3F=3D Date: Sun, 29 Nov 2015 17:33:08 +0100 Subject: [PATCH] eutils.eclass: In EAPI conditionals, replace "has" by case statements. --- eclass/eutils.eclass | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/eclass/eutils.eclass b/eclass/eutils.eclass index 5c7d1aa..1163051 100644 --- a/eclass/eutils.eclass +++ b/eclass/eutils.eclass @@ -1614,7 +1614,8 @@ check=5Flicense() { =09die "you no longer need this as portage supports ACCEPT=5FLICENSE i= tself" } =20 -if has "${EAPI:-0}" 0 1 2; then +case ${EAPI:-0} in +0|1|2) =20 # @FUNCTION: epause # @USAGE: [seconds] @@ -1646,7 +1647,8 @@ ebeep() { =09fi } =20 -else +;; +*) =20 ebeep() { =09ewarn "QA Notice: ebeep is not defined in EAPI=3D${EAPI}, please fi= le a bug at https://bugs.gentoo.org" @@ -1656,9 +1658,11 @@ epause() { =09ewarn "QA Notice: epause is not defined in EAPI=3D${EAPI}, please f= ile a bug at https://bugs.gentoo.org" } =20 -fi +;; +esac =20 -if has "${EAPI:-0}" 0 1 2 3 4; then +case ${EAPI:-0} in +0|1|2|3|4) =20 # @FUNCTION: usex # @USAGE: [true output] [false output] [true suffix] [false= suffix] @@ -1669,9 +1673,11 @@ if has "${EAPI:-0}" 0 1 2 3 4; then # otherwise echo [false output][false suffix] (defaults to "no"). usex() { use "$1" && echo "${2-yes}$4" || echo "${3-no}$5" ; } #382963= =20 -fi +;; +esac =20 -if has "${EAPI:-0}" 0 1 2 3 4 5; then +case ${EAPI:-0} in +0|1|2|3|4|5) =20 # @VARIABLE: EPATCH=5FUSER=5FSOURCE # @DESCRIPTION: @@ -1821,4 +1827,5 @@ in=5Fiuse() { =09has "${flag}" "${liuse[@]#[+-]}" } =20 -fi +;; +esac --=20 2.6.3 --pgp+signed+GNJk9+dlp3WSnIq Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQEcBAEBCAAGBQJWWyw+AAoJEMMJBoUcYcJzSA4H/jY+cVprGnbnpqkof7NPTXZB piFPNNPtfx4rXss9XCt4WK+D1/QuqdYVoeK+qY8T1MpZXdjnFD9esG7tdayIv8ai UAs2pFlvaDHtGi2hRZko/TiDxt8KnPZfrHVVLf44ZVpf4fiLU7xYADtlTMBI+JhO FmfZzi8i6da/11fdkbj3EDyHbzrWWofdpPaaajbESzc7Ms/Og0ugLwVrFtmeq2JR bwCrcHSAxKdK0TZ7/P68eUKvJeM7rJCPELtENboWD1rn/wDBQ9bweMxRrHWnEJgh zO/Sj5cFir3zhbx3cSpap7IMu/BvzlVd5bLBwvfOMHx4o7K+4q6GGNpuAuVXrwo= =FgqA -----END PGP SIGNATURE----- --pgp+signed+GNJk9+dlp3WSnIq--