summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--gentoo70
2 files changed, 42 insertions, 34 deletions
diff --git a/ChangeLog b/ChangeLog
index fdfa892..f819d1f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,13 @@
2005-03-29 Aaron Walker <ka0ttic@gentoo.org>
- * Removed all occurrences of $grepcmd and $sedcmd from _emerge.
+ * Tagged 20050329 release.
* Added metadata.xml to the list of excludes when completing on
category/package, so that _emerge won't complete on
'category/metadata.xml'.
+ * Fixed cases where quoting and a condition (">= fex) failed to
+ complete properly.
+ * Converted all extended regular expressions to bash extglobs in
+ _emerge. ***NO*** external calls exist anymore :)
2005-03-22 Aaron Walker <ka0ttic@gentoo.org>
diff --git a/gentoo b/gentoo
index dacf098..5d6efef 100644
--- a/gentoo
+++ b/gentoo
@@ -142,8 +142,8 @@ _pkgname()
have emerge && {
_emerge()
{
- local cur curword numwords compwords opts cond prepend
- local words stopre stophere i
+ local c cur curword numwords compwords opts cond prepend
+ local words stopre stophere i x
local action actionpos actionre sysactions eactions pkgpos
local version_mode searchdesc_mode help_mode resume_mode
local portdir=$(_portdir -o)
@@ -152,14 +152,21 @@ _emerge()
numwords=${#COMP_WORDS[*]}
curword=${COMP_CWORD}
compwords="${COMP_WORDS[*]}"
- actionre=' (-[CPcis]|(metadata|s(y(nc|stem)|earch)|regen|(unmerg|prun)e|world|((dep)?clean)|(in(fo|ject))))\b'
- stopre=' (depclean|info|metadata|regen|sy(nc|stem)|world|--(resume|s(kipfirst|ync)))\b'
+ actionre=' @(-[CPcis]|@(metadata|s@(y@(nc|stem)|earch)|regen|@(unmerg|prune)e|world|@(@(dep)@(clean)|@(in@(fo|ject)))))'
+ stopre=' @(depclean|info|metadata|regen|sy@(nc|stem)|world|--@(resume|s@(kipfirst|ync)))'
opts=''
- # Test for action.
- action=$(echo "${compwords}" | egrep -o --regex="${actionre}" | tr -d ' ')
+
+ # find action
+ for x in ${compwords} ; do
+ if [[ ${x} == ${actionre} ]] ; then
+ action=${x}
+ break
+ fi
+ done
+
if [[ -n "${action}" ]]; then
for ((i = 0; i < ${numwords}; i++ )); do
- if [[ "${COMP_WORDS[${i}]}" == "${action}" ]]; then
+ if [[ ${COMP_WORDS[${i}]} == "${action}" ]]; then
actionpos=${i}
pkgpos=$((actionpos + 1))
break
@@ -185,13 +192,13 @@ _emerge()
fi
# Check for special cases.
- version_mode=$(echo "${compwords}" | egrep -o -regexp=" -(V|-version)\b")
- searchdesc_mode=$(echo "${compwords}" | egrep -o --regexp=" -(S|-searchdesc)\b")
- help_mode=$(echo "${compwords}" | egrep -o --regexp=" -(h|-help)\b")
+ [[ ${compwords} == *-@(V|-version)* ]] && version_mode=1
+ [[ ${compwords} == *-@(S|-searchdesc)* ]] && searchdesc_mode=1
+ [[ ${compwords} == *-@(h|-help)* ]] && help_mode=1
# Handle special cases.
- if [[ "${action}" = 'search' ]] || [[ "${searchdesc_mode}" ]] || \
- [[ "${version_mode}" ]] || [[ "${action}" = 'metadata' ]]
+ if [[ "${action}" == 'search' ]] || [[ -n "${searchdesc_mode}" ]] || \
+ [[ -n "${version_mode}" ]] || [[ "${action}" == 'metadata' ]]
then
unset COMPREPLY
return 0
@@ -204,12 +211,14 @@ _emerge()
# Complete on options.
if [[ "${cur}" == -* ]]; then
# If a resume option was specified, it needs special handling.
- resume_mode=$(echo "${compwords}" | egrep -o --regexp=" --(resume|skipfirst)\b")
- if [[ -n "${resume_mode}" ]]; then
+ [[ ${compwords} == *--@(resume|skipfirst)* ]] && resume_mode=1
+
+ if [[ -n "${resume_mode}" ]]; then
if [[ "${cur}" == --* ]]; then
opts="--ask --pretend --resume --skipfirst"
elif [[ "${cur}" == -* ]]; then
- [[ -z $(echo "${compwords}" | egrep -o --regexp=" --(ask|pretend)\b") ]] && opts="-a -p"
+ [[ ${compwords} == *--@(ask|pretend)* ]] && ask_premode=1
+ [[ -n "${ask_premode}" ]] && opts="-a -p"
fi
elif [[ "${cur}" == --* ]]; then
# Complete on long options.
@@ -242,7 +251,6 @@ _emerge()
fi
fi
- # Generate the reply.
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
# NOTE: This slows things down!
@@ -265,18 +273,11 @@ _emerge()
fi
# Stop completion if a special case is encountered.
- stophere=$(echo "${compwords}" | egrep -o --regex="${stopre}")
- if [[ -n "${stophere}" ]]; then
+ if [[ ${compwords} == *${stopre}* ]] ; then
unset COMPREPLY
return 0
fi
- # Complete on filenames if given a path.
-# if [[ "${cur} " == @('/'|'.'|'~'|'$')* ]]; then
-# COMPREPLY=($(compgen -G "${cur}*"))
-# return 0
-# fi
-
# Complete on installed packages when unmerging.
if [[ "${action}" == 'unmerge' ]]; then
if [[ -n "${cur}" ]] ; then
@@ -308,7 +309,13 @@ _emerge()
# Check for conditional.
cond="${cur%%[A-Za-z0-9]*}"
cur="${cur:${#cond}}"
- [[ ${cond:0:1} == "'" || ${cond:0:1} == '"' ]] && prepend="-P ${cond:1}"
+ if [[ ${cond:0:1} == "'" || ${cond:0:1} == '"' ]] ; then
+ prepend="-P ${cond:1}"
+ c="${cond:1}"
+ else
+ c="${cond}"
+ fi
+
# Handle cases where a conditional is specified.
if [[ -n "${cond}" ]]; then
@@ -320,20 +327,18 @@ _emerge()
builtin cd ${pd} ; \
local cat="${cur%/*}" ; \
local pkg="$(echo ${cur%-[0-9]*})" ; \
- pkg="${pkg##*/}"
+ pkg="${pkg##*/}" ; \
for x in ${cat}/${pkg}/*.ebuild ; do \
[[ -f ${x} ]] || continue ; \
x="${x/${pkg}\/}" ; \
echo "${x%*.ebuild}" ; \
done ; \
done)"
-
-# words=$(compgen ${prepend} -W "${words}" -- ${cur})
else
words="$(\
for pd in ${portdir} ; do \
builtin cd ${pd}; \
- compgen ${prepend} -G "${cur}*" -- ${cur} ; \
+ compgen -X "*metadata.xml" -G "${cur}*" -- ${cur} ; \
done)"
fi
@@ -356,16 +361,16 @@ _emerge()
builtin cd ${pd} ; \
local cat="${cur%/*}" ; \
local pkg="$(echo ${cur%-[0-9]*}*)" ; \
- pkg="${pkg##*/}"
+ pkg="${pkg##*/}" ; \
for x in ${cat}/${pkg}/*.ebuild ; do \
[[ -f "${x}" ]] || continue ; \
x="${x/${pkg}\/}" ; \
- echo "${x%*.ebuild}" ; \
+ echo "${c}${x%*.ebuild}" ; \
done ; \
fi ; \
done))
else
- COMPREPLY=($(compgen -W "${words}" -- $cur))
+ COMPREPLY=($(compgen ${prepend} -W "${words}" -- $cur))
fi
else
words="$(\
@@ -386,7 +391,6 @@ _emerge()
builtin cd ${pd} ; \
compgen ${prepend} -G "${cur}*/*" -- "${cur}" ; \
done))
-
fi
else
words="$(\