summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2011-03-29 08:46:56 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2011-03-29 08:46:56 +0000
commit35004b546d20244ba560d0d2471a9760802ab0fa (patch)
tree36d71cb67684b3f667c9cca6667e9ce10aeed1d0
parent67847a96ee2bff708b2f7b6ec25cc850f818ea46 (diff)
downloadzsh-35004b546d20244ba560d0d2471a9760802ab0fa.tar.gz
zsh-35004b546d20244ba560d0d2471a9760802ab0fa.zip
Mikael: 28948: compdef -e overrides interpretation of argument as service
-rw-r--r--ChangeLog7
-rw-r--r--Completion/compinit7
-rw-r--r--Doc/Zsh/compsys.yo15
3 files changed, 19 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 050d6af19..16b33345c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-03-29 Peter Stephenson <pws@csr.com>
+
+ * Mikael: 28948: Completion/compinit, Doc/Zsh/compsys.yo:
+ compdef -e overrides interpretation of argument as service.
+
2011-03-27 Peter Stephenson <p.w.stephenson@ntlworld.com>
* Mikael: 28941: Src/Zle/zle_params.c: accessing cursor with
@@ -14377,5 +14382,5 @@
*****************************************************
* This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.5231 $
+* $Revision: 1.5232 $
*****************************************************
diff --git a/Completion/compinit b/Completion/compinit
index aa42a12de..fc3625fc7 100644
--- a/Completion/compinit
+++ b/Completion/compinit
@@ -229,7 +229,7 @@ comppostfuncs=()
# delete the definitions for the command names `bar' and `baz'
compdef() {
- local opt autol type func delete new i ret=0 cmd svc
+ local opt autol type func delete eval new i ret=0 cmd svc
local -a match mbegin mend
emulate -L zsh
@@ -242,7 +242,7 @@ compdef() {
return 1
fi
- while getopts "anpPkKd" opt; do
+ while getopts "anpPkKde" opt; do
case "$opt" in
a) autol=yes;;
n) new=yes;;
@@ -263,6 +263,7 @@ compdef() {
fi
;;
d) delete=yes;;
+ e) eval=yes;;
esac
done
shift OPTIND-1
@@ -276,7 +277,7 @@ compdef() {
# If the first word contains an equal sign, all words must contain one
# and we define which services to use for the commands.
- if [[ "$1" = *\=* ]]; then
+ if [[ -z "$eval" ]] && [[ "$1" = *\=* ]]; then
while (( $# )); do
if [[ "$1" = *\=* ]]; then
cmd="${1%%\=*}"
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index f878ebcab..1eefbcdc8 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -447,7 +447,7 @@ directly.
findex(compdef)
cindex(completion system, adding definitions)
startitem()
-xitem(tt(compdef) [ tt(-an) ] var(function names...) [ tt(-[pP]) var(patterns...) [ tt(-N) var(names...) ] ])
+xitem(tt(compdef) [ tt(-ane) ] var(function names...) [ tt(-[pP]) var(patterns...) [ tt(-N) var(names...) ] ])
xitem(tt(compdef -d) var(names...))
xitem(tt(compdef -k) [ tt(-an) ] var(function style key-sequences...))
item(tt(compdef -K) [ tt(-an) ] var(function name style key-sequences ...))(
@@ -460,11 +460,14 @@ defined by `var(cmd1)tt(=)var(service)' lines in tt(#compdef) files, as
described above. The argument for var(cmd) will be completed in the
same way as var(service).
-The var(function) argument may alternatively be a string containing any
-shell code. The string will be executed using the tt(eval) builtin
-command to generate completions. This provides a way of avoiding having
-to define a new completion function. For example, to complete
-files ending in `tt(.h)' as arguments to the command tt(foo):
+The var(function) argument may alternatively be a string containing
+almost any shell code. If the string contains an equal sign, the above
+will take precedence. The option -e may be used to specify the first
+argument is to be evaluated as shell code even if it contains an equal
+sign. The string will be executed using the tt(eval) builtin command to
+generate completions. This provides a way of avoiding having to define
+a new completion function. For example, to complete files ending in
+`tt(.h)' as arguments to the command tt(foo):
example(compdef '_files -g "*.h"' foo)