summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2006-03-16 04:18:53 +0000
committerMike Frysinger <vapier@gentoo.org>2006-03-16 04:18:53 +0000
commit659eafddd5964820ce8bdc0d90f5fcf7df04b5b7 (patch)
tree678527b531911846e44697f0b7a2cec17c47fa1f /bin
parent8ec4fe45deeeb331c478a96ea494f035832dedb8 (diff)
downloadportage-659eafddd5964820ce8bdc0d90f5fcf7df04b5b7.tar.gz
portage-659eafddd5964820ce8bdc0d90f5fcf7df04b5b7.tar.bz2
portage-659eafddd5964820ce8bdc0d90f5fcf7df04b5b7.zip
cleanup bash code in use*() and has*() functions with the help of agriffis
svn path=/main/trunk/; revision=2903
Diffstat (limited to 'bin')
-rwxr-xr-xbin/ebuild.sh56
1 files changed, 15 insertions, 41 deletions
diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index 26bd235e8..3f3e14343 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -103,10 +103,7 @@ esyslog() {
use() {
- if useq ${1}; then
- return 0
- fi
- return 1
+ useq ${1}
}
usev() {
@@ -118,64 +115,41 @@ usev() {
}
useq() {
- local u="${1}"
- local neg=0
- if [ "${u:0:1}" == "!" ]; then
- u="${u:1}"
- neg=1
+ local u=$1
+ local found=0
+
+ # if we got something like '!flag', then invert the return value
+ if [[ ${u:0:1} == "!" ]] ; then
+ u=${u:1}
+ found=1
fi
- local x
# Make sure we have this USE flag in IUSE
if ! hasq "${u}" ${IUSE} ${E_IUSE} && ! hasq "${u}" ${PORTAGE_ARCHLIST} selinux; then
echo "QA Notice: USE Flag '${u}' not in IUSE for ${CATEGORY}/${PF}" >&2
fi
- for x in ${USE}; do
- if [ "${x}" == "${u}" ]; then
- if [ ${neg} -eq 1 ]; then
- return 1
- else
- return 0
- fi
- fi
- done
- if [ ${neg} -eq 1 ]; then
- return 0
+ if [[ " ${USE} " == *" ${u} "* ]] ; then
+ return ${found}
else
- return 1
+ return $((!found))
fi
}
has() {
- if hasq "$@"; then
- return 0
- fi
- return 1
+ hasq "$@"
}
hasv() {
- if hasq "$@"; then
- echo "${1}"
+ if hasq "$@" ; then
+ echo "$1"
return 0
fi
return 1
}
hasq() {
- local x
-
- local me=$1
- shift
-
- # All the TTY checks really only help out depend. Which is nice.
- # Logging kills all this anyway. Everything becomes a pipe. --NJ
- for x in "$@"; do
- if [ "${x}" == "${me}" ]; then
- return 0
- fi
- done
- return 1
+ [[ " ${*:2} " == *" $1 "* ]]
}
has_version() {