- 'make' completion rewrite by Guillaume Rousse <rousse@ccr.jussieu.fr>
This commit is contained in:
parent
1a542a6164
commit
1fdddc3d64
108
bash_completion
108
bash_completion
@ -1,6 +1,6 @@
|
|||||||
# bash_completion - some programmable completion functions for bash 2.05b
|
# bash_completion - some programmable completion functions for bash 2.05b
|
||||||
#
|
#
|
||||||
# $Id: bash_completion,v 1.600 2003/08/03 03:07:38 ianmacd Exp $
|
# $Id: bash_completion,v 1.601 2003/08/03 03:19:30 ianmacd Exp $
|
||||||
#
|
#
|
||||||
# Copyright (C) Ian Macdonald <ian@caliban.org>
|
# Copyright (C) Ian Macdonald <ian@caliban.org>
|
||||||
#
|
#
|
||||||
@ -2213,69 +2213,77 @@ _route()
|
|||||||
have make &&
|
have make &&
|
||||||
_make()
|
_make()
|
||||||
{
|
{
|
||||||
local mdef makef gcmd cur prev i
|
local makef cur prev i
|
||||||
|
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
cur=${COMP_WORDS[COMP_CWORD]}
|
cur=${COMP_WORDS[COMP_CWORD]}
|
||||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||||
|
|
||||||
# if prev argument is -f, return possible filename completions.
|
case $prev in
|
||||||
# we could be a little smarter here and return matches against
|
-@(f|o|W))
|
||||||
# `makefile Makefile *.mk', whatever exists
|
_filedir
|
||||||
if [[ "$prev" == -*f ]]; then
|
return 0
|
||||||
_filedir
|
;;
|
||||||
return 0
|
-@(I|C))
|
||||||
fi
|
_filedir -d
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# check for a long option
|
case $cur in
|
||||||
if [[ "$cur" == --* ]]; then
|
--@(file=|makefile=))
|
||||||
_longopt $1
|
_filedir
|
||||||
return 0
|
return 0
|
||||||
fi
|
;;
|
||||||
|
--@(directory=|include-dir=))
|
||||||
|
_filedir -d
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# if we want an option, return the possible posix options
|
|
||||||
if [[ "$cur" == -* ]]; then
|
if [[ "$cur" == -* ]]; then
|
||||||
COMPREPLY=( $( compgen -W '-e -f -i -k -n -p -q -r -S -s -t' \
|
COMPREPLY=( $( compgen -W '-b -m -B -C -d -e -f -h -i -I\
|
||||||
-- $cur ) )
|
-j -l -k -n -o -p -q -r -R - s -S -t -v -w -W \
|
||||||
return 0
|
--always-make --directory= --debug \
|
||||||
fi
|
--environment-overrides --file= --makefile= --help \
|
||||||
|
--ignore-errors --include-dir= --jobs --load-average \
|
||||||
# make reads `GNUmakefile', then `makefile', then `Makefile'
|
--max-load --keep-going --just-print --dry-run \
|
||||||
if [ -f GNUmakefile ]; then
|
--recon --old-file= --assume-old= --print-data-base \
|
||||||
mdef=GNUmakefile
|
--question --no-builtin-rules --no-builtin-variables \
|
||||||
elif [ -f makefile ]; then
|
--silent --quiet --no-keep-goind --stop --touch \
|
||||||
mdef=makefile
|
--version --print-directory --no-print-directory \
|
||||||
elif [ -f Makefile ]; then
|
--what-if= --new-file= --assume-new= \
|
||||||
mdef=Makefile
|
--warn-undefined-variables' -- $cur ) )
|
||||||
else
|
else
|
||||||
mdef=*.mk # local convention
|
# make reads `GNUmakefile', then `makefile', then `Makefile'
|
||||||
fi
|
if [ -f GNUmakefile ]; then
|
||||||
|
makef=GNUmakefile
|
||||||
# before we scan for targets, see if a makefile name was specified
|
elif [ -f makefile ]; then
|
||||||
# with -f
|
makef=makefile
|
||||||
for (( i=0; i < ${#COMP_WORDS[@]}; i++ )); do
|
elif [ -f Makefile ]; then
|
||||||
if [[ ${COMP_WORDS[i]} == -*f ]]; then
|
makef=Makefile
|
||||||
eval makef=${COMP_WORDS[i+1]} # eval for tilde expansion
|
else
|
||||||
break
|
makef=*.mk # local convention
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
|
|
||||||
[ -z "$makef" ] && makef=$mdef
|
# before we scan for targets, see if a makefile name was specified
|
||||||
|
# with -f
|
||||||
|
for (( i=0; i < ${#COMP_WORDS[@]}; i++ )); do
|
||||||
|
if [[ ${COMP_WORDS[i]} == -f ]]; then
|
||||||
|
# eval for tilde expansion
|
||||||
|
eval makef=${COMP_WORDS[i+1]}
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
# if we have a partial word to complete, restrict completions to
|
[ ! -f $makef ] && return 0
|
||||||
# matches of that word
|
|
||||||
[ -n "$2" ] && gcmd='grep "^$2"' || gcmd=cat
|
|
||||||
|
|
||||||
COMPREPLY=( $( grep -v '^\w\w*[[:space:]]*:=' $makef 2>/dev/null | \
|
COMPREPLY=( $( awk -F':' '/^[^\t ]*:/ {print $1}' $makef \
|
||||||
awk 'BEGIN {FS=":"} /^[^.#'$'\t''][^=]*:/ {print $1}' | \
|
2>/dev/null | grep -v "^[.%#]" | grep "^$cur" ))
|
||||||
eval $gcmd ) )
|
|
||||||
|
|
||||||
# default to filename completion if all else failed
|
fi
|
||||||
[ ${#COMPREPLY[@]} -eq 0 ] && _filedir
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
[ -n "${have:-}" ] && complete -F _make -X '+($*|*.[ch])' $default $filenames make gmake pmake
|
[ -n "${have:-}" ] && complete -F _make $default $filenames make gmake pmake
|
||||||
|
|
||||||
# GNU tar(1) completion
|
# GNU tar(1) completion
|
||||||
#
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user