Gentoo Archives: gentoo-dev

From: Mike Frysinger <vapier@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in net-misc/openvpn: ChangeLog openvpn-2.1.3.ebuild
Date: Wed, 13 Oct 2010 18:52:20
Message-Id: 201010131451.35784.vapier@gentoo.org
In Reply to: Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in net-misc/openvpn: ChangeLog openvpn-2.1.3.ebuild by Mike Frysinger
1 here's what i'll commit to eutils.eclass:
2
3 # @FUNCTION: path_exists
4 # @USAGE: [-a|-o] <paths>
5 # @DESCRIPTION:
6 # Check if the specified paths exist. Works for all types of paths
7 # (files/dirs/etc...). The -a and -o flags control the requirements
8 # of the paths. They correspond to "and" and "or" logic. So the -a
9 # flag means all the paths must exist while the -o flag means at least
10 # one of the paths must exist. The default behavior is "and". If no
11 # paths are specified, then the return value is "false".
12 path_exists() {
13 local opt=$1
14 [[ ${opt} == -[ao] ]] && shift || opt="-a"
15
16 # no paths -> return false
17 # same behavior as: [[ -e "" ]]
18 [[ $# -eq 0 ]] && return 1
19
20 local p r=0
21 for p in "$@" ; do
22 [[ -e ${p} ]]
23 : $(( r += $? ))
24 done
25
26 case ${opt} in
27 -a) return $(( r != 0 )) ;;
28 -o) return $(( r == $# )) ;;
29 esac
30 }
31 -mike

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies