commit:     5f97ce827b9db74b9b5ebf76f868726180d07ebb
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Aug  9 15:11:04 2018 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Aug 15 07:31:00 2018 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5f97ce82

eutils.eclass: Ban path_exists

Closes: https://github.com/gentoo/gentoo/pull/9517

 eclass/eutils.eclass               | 30 ++++--------------------------
 eclass/tests/eutils_path_exists.sh | 35 -----------------------------------
 2 files changed, 4 insertions(+), 61 deletions(-)

diff --git a/eclass/eutils.eclass b/eclass/eutils.eclass
index e5d0ebeebb0..7b6336e2aee 100644
--- a/eclass/eutils.eclass
+++ b/eclass/eutils.eclass
@@ -168,33 +168,11 @@ make_wrapper() {
        fi
 }
 
-# @FUNCTION: path_exists
-# @USAGE: [-a|-o] <paths>
-# @DESCRIPTION:
-# Check if the specified paths exist.  Works for all types of paths
-# (files/dirs/etc...).  The -a and -o flags control the requirements
-# of the paths.  They correspond to "and" and "or" logic.  So the -a
-# flag means all the paths must exist while the -o flag means at least
-# one of the paths must exist.  The default behavior is "and".  If no
-# paths are specified, then the return value is "false".
 path_exists() {
-       local opt=$1
-       [[ ${opt} == -[ao] ]] && shift || opt="-a"
-
-       # no paths -> return false
-       # same behavior as: [[ -e "" ]]
-       [[ $# -eq 0 ]] && return 1
-
-       local p r=0
-       for p in "$@" ; do
-               [[ -e ${p} ]]
-               : $(( r += $? ))
-       done
-
-       case ${opt} in
-               -a) return $(( r != 0 )) ;;
-               -o) return $(( r == $# )) ;;
-       esac
+       eerror "path_exists has been removed.  Please see the following post"
+       eerror "for a replacement snippet:"
+       eerror 
"https://blogs.gentoo.org/mgorny/2018/08/09/inlining-path_exists/";
+       die "path_exists is banned"
 }
 
 # @FUNCTION: use_if_iuse

diff --git a/eclass/tests/eutils_path_exists.sh 
b/eclass/tests/eutils_path_exists.sh
deleted file mode 100755
index 00a89c7e446..00000000000
--- a/eclass/tests/eutils_path_exists.sh
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/bash
-# Copyright 1999-2015 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-source tests-common.sh
-
-inherit eutils
-
-test-path_exists() {
-       local exp=$1; shift
-       tbegin "path_exists($*) == ${exp}"
-       path_exists "$@"
-       [[ ${exp} -eq $? ]]
-       tend $?
-}
-
-test-path_exists 1
-test-path_exists 1 -a
-test-path_exists 1 -o
-
-good="/ . tests-common.sh /bin/bash"
-test-path_exists 0 ${good}
-test-path_exists 0 -a ${good}
-test-path_exists 0 -o ${good}
-
-bad="/asjdkfljasdlfkja jlakjdsflkasjdflkasdjflkasdjflaskdjf"
-test-path_exists 1 ${bad}
-test-path_exists 1 -a ${bad}
-test-path_exists 1 -o ${bad}
-
-test-path_exists 1 ${good} ${bad}
-test-path_exists 1 -a ${good} ${bad}
-test-path_exists 0 -o ${good} ${bad}
-
-texit

Reply via email to