mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-08 12:01:21 +02:00
29365: redefine _make() in _make.
This commit is contained in:
parent
32d7fea7a7
commit
a75cbae6b7
2 changed files with 77 additions and 69 deletions
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
* 29331: NEWS: Note g:: parameter expansion flag.
|
* 29331: NEWS: Note g:: parameter expansion flag.
|
||||||
|
|
||||||
|
* 29365: Completion/Unix/Command/_make: redefine _make so that
|
||||||
|
helper functions are only defined once.
|
||||||
|
|
||||||
2011-05-26 Peter Stephenson <pws@csr.com>
|
2011-05-26 Peter Stephenson <pws@csr.com>
|
||||||
|
|
||||||
* unposted: Etc/CONTRIBUTORS: expand.
|
* unposted: Etc/CONTRIBUTORS: expand.
|
||||||
|
@ -14831,5 +14834,5 @@
|
||||||
|
|
||||||
*****************************************************
|
*****************************************************
|
||||||
* This is used by the shell to define $ZSH_PATCHLEVEL
|
* This is used by the shell to define $ZSH_PATCHLEVEL
|
||||||
* $Revision: 1.5332 $
|
* $Revision: 1.5333 $
|
||||||
*****************************************************
|
*****************************************************
|
||||||
|
|
|
@ -3,10 +3,6 @@
|
||||||
# TODO: Based on targets given on the command line, show only variables that
|
# TODO: Based on targets given on the command line, show only variables that
|
||||||
# are used in those targets and their dependencies.
|
# are used in those targets and their dependencies.
|
||||||
|
|
||||||
local prev="$words[CURRENT-1]" file expl tmp is_gnu dir incl match
|
|
||||||
local -A TARGETS VARIABLES
|
|
||||||
local ret=1
|
|
||||||
|
|
||||||
_make-expandVars() {
|
_make-expandVars() {
|
||||||
local open close var val front ret tmp=$1
|
local open close var val front ret tmp=$1
|
||||||
|
|
||||||
|
@ -149,77 +145,86 @@ _make-findBasedir () {
|
||||||
print -- $basedir
|
print -- $basedir
|
||||||
}
|
}
|
||||||
|
|
||||||
_pick_variant -r is_gnu gnu=GNU unix -v -f
|
_make() {
|
||||||
|
|
||||||
if [[ $is_gnu == gnu ]]
|
local prev="$words[CURRENT-1]" file expl tmp is_gnu dir incl match
|
||||||
then
|
local -A TARGETS VARIABLES
|
||||||
incl="(-|)include"
|
local ret=1
|
||||||
else
|
|
||||||
incl=.include
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$prev" == -[CI] ]]
|
_pick_variant -r is_gnu gnu=GNU unix -v -f
|
||||||
then
|
|
||||||
_files -W ${(q)$(_make-findBasedir ${words[1,CURRENT-1]})} -/ && ret=0
|
if [[ $is_gnu == gnu ]]
|
||||||
elif [[ "$prev" == -[foW] ]]
|
|
||||||
then
|
|
||||||
_files -W ${(q)$(_make-findBasedir $words)} && ret=0
|
|
||||||
else
|
|
||||||
file="$words[(I)-f]"
|
|
||||||
if (( file ))
|
|
||||||
then
|
then
|
||||||
file=${~words[file+1]}
|
incl="(-|)include"
|
||||||
[[ $file == [^/]* ]] && file=${(q)$(_make-findBasedir $words)}/$file
|
|
||||||
[[ -r $file ]] || file=
|
|
||||||
else
|
else
|
||||||
local basedir
|
incl=.include
|
||||||
basedir=${$(_make-findBasedir $words)}
|
fi
|
||||||
if [[ $is_gnu == gnu && -r $basedir/GNUmakefile ]]
|
|
||||||
|
if [[ "$prev" == -[CI] ]]
|
||||||
|
then
|
||||||
|
_files -W ${(q)$(_make-findBasedir ${words[1,CURRENT-1]})} -/ && ret=0
|
||||||
|
elif [[ "$prev" == -[foW] ]]
|
||||||
|
then
|
||||||
|
_files -W ${(q)$(_make-findBasedir $words)} && ret=0
|
||||||
|
else
|
||||||
|
file="$words[(I)-f]"
|
||||||
|
if (( file ))
|
||||||
then
|
then
|
||||||
file=$basedir/GNUmakefile
|
file=${~words[file+1]}
|
||||||
elif [[ -r $basedir/makefile ]]
|
[[ $file == [^/]* ]] && file=${(q)$(_make-findBasedir $words)}/$file
|
||||||
then
|
[[ -r $file ]] || file=
|
||||||
file=$basedir/makefile
|
|
||||||
elif [[ -r $basedir/Makefile ]]
|
|
||||||
then
|
|
||||||
file=$basedir/Makefile
|
|
||||||
else
|
else
|
||||||
file=''
|
local basedir
|
||||||
|
basedir=${$(_make-findBasedir $words)}
|
||||||
|
if [[ $is_gnu == gnu && -r $basedir/GNUmakefile ]]
|
||||||
|
then
|
||||||
|
file=$basedir/GNUmakefile
|
||||||
|
elif [[ -r $basedir/makefile ]]
|
||||||
|
then
|
||||||
|
file=$basedir/makefile
|
||||||
|
elif [[ -r $basedir/Makefile ]]
|
||||||
|
then
|
||||||
|
file=$basedir/Makefile
|
||||||
|
else
|
||||||
|
file=''
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$file" ]]
|
||||||
|
then
|
||||||
|
if [[ $is_gnu == gnu ]] && zstyle -t ":completion:${curcontext}:targets" call-command
|
||||||
|
then
|
||||||
|
_make-parseMakefile $PWD < <(_call_program targets "$words[1]" -nsp --no-print-directory -f "$file" .PHONY 2> /dev/null)
|
||||||
|
else
|
||||||
|
case "$OSTYPE" in
|
||||||
|
freebsd*)
|
||||||
|
_make-parseMakefile $PWD < <(_call_program targets "$words[1]" -nsp -f "$file" .PHONY 2> /dev/null)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
_make-parseMakefile $PWD < $file
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $PREFIX == *'='* ]]
|
||||||
|
then
|
||||||
|
# Complete make variable as if shell variable
|
||||||
|
compstate[parameter]="${PREFIX%%\=*}"
|
||||||
|
compset -P 1 '*='
|
||||||
|
_value "$@" && ret=0
|
||||||
|
else
|
||||||
|
_tags targets variables
|
||||||
|
while _tags
|
||||||
|
do
|
||||||
|
_requested targets expl 'make targets' \
|
||||||
|
compadd -- ${(k)TARGETS} && ret=0
|
||||||
|
_requested variables expl 'make variables' \
|
||||||
|
compadd -S '=' -- ${(k)VARIABLES} && ret=0
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "$file" ]]
|
return ret
|
||||||
then
|
}
|
||||||
if [[ $is_gnu == gnu ]] && zstyle -t ":completion:${curcontext}:targets" call-command
|
|
||||||
then
|
|
||||||
_make-parseMakefile $PWD < <(_call_program targets "$words[1]" -nsp --no-print-directory -f "$file" .PHONY 2> /dev/null)
|
|
||||||
else
|
|
||||||
case "$OSTYPE" in
|
|
||||||
freebsd*)
|
|
||||||
_make-parseMakefile $PWD < <(_call_program targets "$words[1]" -nsp -f "$file" .PHONY 2> /dev/null)
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
_make-parseMakefile $PWD < $file
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $PREFIX == *'='* ]]
|
_make "$@"
|
||||||
then
|
|
||||||
# Complete make variable as if shell variable
|
|
||||||
compstate[parameter]="${PREFIX%%\=*}"
|
|
||||||
compset -P 1 '*='
|
|
||||||
_value "$@" && ret=0
|
|
||||||
else
|
|
||||||
_tags targets variables
|
|
||||||
while _tags
|
|
||||||
do
|
|
||||||
_requested targets expl 'make targets' \
|
|
||||||
compadd -- ${(k)TARGETS} && ret=0
|
|
||||||
_requested variables expl 'make variables' \
|
|
||||||
compadd -S '=' -- ${(k)VARIABLES} && ret=0
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
return ret
|
|
||||||
|
|
Loading…
Reference in a new issue