Gentoo Archives: gentoo-dev

From: "M. J. Everitt" <m.j.everitt@×××.org>
To: gentoo-dev@l.g.o, "Michał Górny" <mgorny@g.o>
Subject: Re: [gentoo-dev] [PATCH 5/5] eutils.eclass: Restore the original path_exists function
Date: Thu, 09 Aug 2018 06:14:07
Message-Id: 335257f3-a01b-3eb8-a107-12957e33ea18@iee.org
In Reply to: [gentoo-dev] [PATCH 5/5] eutils.eclass: Restore the original path_exists function by "Michał Górny"
1 On 08/08/18 22:34, Michał Górny wrote [excerpted]:
2 > +# Example:
3 > +# @CODE
4 > +# if path_exists "${ROOT}"/etc/foo.d/*.conf; then
5 > +# do_something
6 > +# fi
7 > +# @CODE
8 > path_exists() {
9 > - local opt=$1
10 > - [[ ${opt} == -[ao] ]] && shift || opt="-a"
11 > -
12 > - # no paths -> return false
13 > - # same behavior as: [[ -e "" ]]
14 > - [[ $# -eq 0 ]] && return 1
15 > -
16 > - local p r=0
17 > - for p in "$@" ; do
18 > - [[ -e ${p} ]]
19 > - : $(( r += $? ))
20 > + local p
21 > + for p; do
22 > + [[ -e ${p} ]] && return 0
23 > done
24 You seem to have lost the inclusion of the function parameters in the
25 execution code - was this intentional?!
26 Regards,
27 Michael.

Attachments

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