Merge remote-tracking branch 'origin/master' into slackware
This commit is contained in:
commit
08d170d2a4
@ -344,7 +344,7 @@ __reassemble_comp_words_by_ref()
|
|||||||
# @param $2 words Name of variable to return words to
|
# @param $2 words Name of variable to return words to
|
||||||
# @param $3 cword Name of variable to return cword to
|
# @param $3 cword Name of variable to return cword to
|
||||||
# @param $4 cur Name of variable to return current word to complete to
|
# @param $4 cur Name of variable to return current word to complete to
|
||||||
# @see ___get_cword_at_cursor_by_ref()
|
# @see __reassemble_comp_words_by_ref()
|
||||||
__get_cword_at_cursor_by_ref()
|
__get_cword_at_cursor_by_ref()
|
||||||
{
|
{
|
||||||
local cword words=()
|
local cword words=()
|
||||||
@ -366,7 +366,7 @@ __get_cword_at_cursor_by_ref()
|
|||||||
((index--))
|
((index--))
|
||||||
done
|
done
|
||||||
|
|
||||||
# Does found word matches cword?
|
# Does found word match cword?
|
||||||
if [[ "$i" -lt "$cword" ]]; then
|
if [[ "$i" -lt "$cword" ]]; then
|
||||||
# No, cword lies further;
|
# No, cword lies further;
|
||||||
local old_size="${#cur}"
|
local old_size="${#cur}"
|
||||||
@ -633,6 +633,7 @@ _filedir()
|
|||||||
|
|
||||||
if [[ "$1" != -d ]]; then
|
if [[ "$1" != -d ]]; then
|
||||||
# Munge xspec to contain uppercase version too
|
# Munge xspec to contain uppercase version too
|
||||||
|
# http://thread.gmane.org/gmane.comp.shells.bash.bugs/15294/focus=15306
|
||||||
xspec=${1:+"!*.@($1|${1^^})"}
|
xspec=${1:+"!*.@($1|${1^^})"}
|
||||||
toks+=( $( compgen -f -X "$xspec" -- $quoted ) )
|
toks+=( $( compgen -f -X "$xspec" -- $quoted ) )
|
||||||
fi
|
fi
|
||||||
@ -736,7 +737,7 @@ _init_completion()
|
|||||||
i=$(( ++i ))
|
i=$(( ++i ))
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
prev=${words[cword-1]}
|
[[ $cword -ge 1 ]] && prev=${words[cword-1]} || prev=
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -747,32 +748,33 @@ _init_completion()
|
|||||||
#
|
#
|
||||||
_parse_help()
|
_parse_help()
|
||||||
{
|
{
|
||||||
# Print first found long option, or first short if not found.
|
local line i option option2 IFS=$' \t\n,/|'
|
||||||
eval local cmd=$1
|
eval local cmd=$1
|
||||||
"$cmd" ${2:---help} 2>&1 | awk \
|
"$cmd" ${2:---help} 2>&1 | while read line; do
|
||||||
'{
|
|
||||||
if ($0 !~ /^[ \t]*-/) { next }
|
[[ $line == *([ $'\t'])-* ]] || continue
|
||||||
gsub("[,/|]", " ");
|
|
||||||
x = -1;
|
# Take first found long option, or first one (short) if not found.
|
||||||
for (i = 1; i <= NF; i++) {
|
option=
|
||||||
if ($i ~ /^--[^-]/) { x = i ; break }
|
for i in $line; do
|
||||||
if ($i !~ /^-/) { break }
|
case $i in
|
||||||
}
|
---*) break ;;
|
||||||
if (x == -1) { x = 1 }
|
--?*) option=$i ; break ;;
|
||||||
if ($x ~ /^---/) { next }
|
-?*) [[ $option ]] || option=$i ;;
|
||||||
if ($x ~ /^--?[[]no[]]./) {
|
*) break ;;
|
||||||
y = $x ; sub("[[]no[]]", "", y)
|
esac
|
||||||
z = $x ; sub("[[]no[]]", "no", z)
|
done
|
||||||
sub("[=<{[].*", "", y)
|
[[ $option ]] || continue
|
||||||
sub("[=<{[].*", "", z)
|
|
||||||
print y
|
# Expand --[no]foo to --foo and --nofoo
|
||||||
print z
|
if [[ $option == *\[no\]?* ]]; then
|
||||||
}
|
option2=${option/\[no\]/}
|
||||||
else {
|
printf '%s\n' "${option2%%[=<{[]*}"
|
||||||
sub("[=<{[].*", "", $x)
|
option=${option/\[no\]/no}
|
||||||
print $x
|
fi
|
||||||
}
|
|
||||||
}'
|
printf '%s\n' "${option%%[=<{[]*}"
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function completes on signal names
|
# This function completes on signal names
|
||||||
@ -1722,6 +1724,7 @@ _filedir_xspec()
|
|||||||
))
|
))
|
||||||
|
|
||||||
# Munge xspec to contain uppercase version too
|
# Munge xspec to contain uppercase version too
|
||||||
|
# http://thread.gmane.org/gmane.comp.shells.bash.bugs/15294/focus=15306
|
||||||
eval xspec="${xspec}"
|
eval xspec="${xspec}"
|
||||||
local matchop=!
|
local matchop=!
|
||||||
if [[ $xspec == !* ]]; then
|
if [[ $xspec == !* ]]; then
|
||||||
|
@ -27,6 +27,7 @@ bashcomp_DATA = abook \
|
|||||||
cowsay \
|
cowsay \
|
||||||
cpan2dist \
|
cpan2dist \
|
||||||
cpio \
|
cpio \
|
||||||
|
cppcheck \
|
||||||
crontab \
|
crontab \
|
||||||
cups \
|
cups \
|
||||||
cryptsetup \
|
cryptsetup \
|
||||||
|
@ -32,7 +32,7 @@ _autoconf()
|
|||||||
$split && return 0
|
$split && return 0
|
||||||
|
|
||||||
if [[ "$cur" == -* ]]; then
|
if [[ "$cur" == -* ]]; then
|
||||||
_longopt $1
|
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ _autoreconf()
|
|||||||
$split && return 0
|
$split && return 0
|
||||||
|
|
||||||
if [[ "$cur" == -* ]]; then
|
if [[ "$cur" == -* ]]; then
|
||||||
_longopt $1
|
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ _autoscan()
|
|||||||
$split && return 0
|
$split && return 0
|
||||||
|
|
||||||
if [[ "$cur" == -* ]]; then
|
if [[ "$cur" == -* ]]; then
|
||||||
_longopt $1
|
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ _automake()
|
|||||||
$split && return 0
|
$split && return 0
|
||||||
|
|
||||||
if [[ "$cur" == -* ]]; then
|
if [[ "$cur" == -* ]]; then
|
||||||
_longopt $1
|
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ _aclocal()
|
|||||||
|
|
||||||
$split && return 0
|
$split && return 0
|
||||||
|
|
||||||
_longopt $1
|
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
|
||||||
} &&
|
} &&
|
||||||
complete -F _aclocal aclocal aclocal-1.11
|
complete -F _aclocal aclocal aclocal-1.11
|
||||||
|
|
||||||
|
62
completions/cppcheck
Normal file
62
completions/cppcheck
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
# bash completion for cppcheck(1)
|
||||||
|
|
||||||
|
have cppcheck || return
|
||||||
|
|
||||||
|
_cppcheck()
|
||||||
|
{
|
||||||
|
local cur prev words cword
|
||||||
|
_init_completion -n = || return
|
||||||
|
|
||||||
|
local split=false
|
||||||
|
_split_longopt && split=true
|
||||||
|
|
||||||
|
case $prev in
|
||||||
|
--append|--exitcode-suppressions|--file-list|--rule-file|\
|
||||||
|
--suppressions-list)
|
||||||
|
_filedir
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
-D*|--rule|--suppress|--template)
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
--enable)
|
||||||
|
COMPREPLY=( $( compgen -W 'all style information unusedFunction
|
||||||
|
missingInclude' -- "$cur" ) )
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
--exitcode)
|
||||||
|
COMPREPLY=( $( compgen -W '{0..255}' -- "$cur" ) )
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
-I|-i)
|
||||||
|
_filedir -d
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
-j)
|
||||||
|
COMPREPLY=( $( compgen -W '{2..16}' -- "$cur" ) )
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
--xml-version)
|
||||||
|
COMPREPLY=( $( compgen -W '1 2' -- "$cur" ) )
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
$split && return
|
||||||
|
|
||||||
|
if [[ $cur == -* ]]; then
|
||||||
|
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
|
||||||
|
[[ $COMPREPLY == @(-D|*=) ]] && compopt -o nospace
|
||||||
|
else
|
||||||
|
_filedir @(cpp|cxx|cc|c++|c|tpp|txx)
|
||||||
|
fi
|
||||||
|
} &&
|
||||||
|
complete -F _cppcheck cppcheck
|
||||||
|
|
||||||
|
# Local variables:
|
||||||
|
# mode: shell-script
|
||||||
|
# sh-basic-offset: 4
|
||||||
|
# sh-indent-comment: t
|
||||||
|
# indent-tabs-mode: nil
|
||||||
|
# End:
|
||||||
|
# ex: ts=4 sw=4 et filetype=sh
|
@ -40,7 +40,8 @@ _xsltproc()
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
if [[ "$cur" == -* ]]; then
|
if [[ "$cur" == -* ]]; then
|
||||||
_longopt xsltproc
|
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
|
||||||
|
COMPREPLY=( "${COMPREPLY[@]%:}" )
|
||||||
else
|
else
|
||||||
_filedir '@(xsl|xslt|xml)'
|
_filedir '@(xsl|xslt|xml)'
|
||||||
fi
|
fi
|
||||||
|
1
test/completion/cppcheck.exp
Normal file
1
test/completion/cppcheck.exp
Normal file
@ -0,0 +1 @@
|
|||||||
|
assert_source_completions cppcheck
|
20
test/lib/completions/cppcheck.exp
Normal file
20
test/lib/completions/cppcheck.exp
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
proc setup {} {
|
||||||
|
save_env
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
proc teardown {} {
|
||||||
|
assert_env_unmodified
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
setup
|
||||||
|
|
||||||
|
|
||||||
|
assert_complete_any "cppcheck "
|
||||||
|
|
||||||
|
|
||||||
|
sync_after_int
|
||||||
|
|
||||||
|
|
||||||
|
teardown
|
@ -48,6 +48,22 @@ assert_bash_list {" a"} $cmd $test
|
|||||||
sync_after_int
|
sync_after_int
|
||||||
|
|
||||||
|
|
||||||
|
set test "|a "; # | = cursor position
|
||||||
|
set cmd {COMP_WORDS=(a); COMP_CWORD=0; COMP_LINE='a '; COMP_POINT=0; _get_comp_words_by_ref cur prev; echo "$cur $prev"}
|
||||||
|
assert_bash_list {" "} $cmd $test
|
||||||
|
|
||||||
|
|
||||||
|
sync_after_int
|
||||||
|
|
||||||
|
|
||||||
|
set test " | a "; # | = cursor position
|
||||||
|
set cmd {COMP_WORDS=(a); COMP_CWORD=0; COMP_LINE=' a '; COMP_POINT=1; _get_comp_words_by_ref cur prev; echo "$cur $prev"}
|
||||||
|
assert_bash_list {" "} $cmd $test
|
||||||
|
|
||||||
|
|
||||||
|
sync_after_int
|
||||||
|
|
||||||
|
|
||||||
set test "a b |"; # | = cursor position
|
set test "a b |"; # | = cursor position
|
||||||
set cmd {COMP_WORDS=(a b ''); COMP_CWORD=2; COMP_LINE='a b '; COMP_POINT=4; _get_comp_words_by_ref cur prev; echo "$cur $prev"}
|
set cmd {COMP_WORDS=(a b ''); COMP_CWORD=2; COMP_LINE='a b '; COMP_POINT=4; _get_comp_words_by_ref cur prev; echo "$cur $prev"}
|
||||||
assert_bash_list {" b"} $cmd $test
|
assert_bash_list {" b"} $cmd $test
|
||||||
@ -72,6 +88,14 @@ assert_bash_list {"b a"} $cmd $test
|
|||||||
sync_after_int
|
sync_after_int
|
||||||
|
|
||||||
|
|
||||||
|
set test "a | b"; # | = cursor position
|
||||||
|
set cmd {COMP_WORDS=(a b); COMP_CWORD=1; COMP_LINE='a b'; COMP_POINT=2; _get_comp_words_by_ref cur prev; echo "$cur $prev"}
|
||||||
|
assert_bash_list {" a"} $cmd $test
|
||||||
|
|
||||||
|
|
||||||
|
sync_after_int
|
||||||
|
|
||||||
|
|
||||||
set test {a b\ c| should return b\ c}; # | = cursor position
|
set test {a b\ c| should return b\ c}; # | = cursor position
|
||||||
set cmd {COMP_WORDS=(a 'b\ c'); COMP_CWORD=1; COMP_LINE='a b\ c'; COMP_POINT=6; _get_comp_words_by_ref cur prev; echo "$cur $prev"}
|
set cmd {COMP_WORDS=(a 'b\ c'); COMP_CWORD=1; COMP_LINE='a b\ c'; COMP_POINT=6; _get_comp_words_by_ref cur prev; echo "$cur $prev"}
|
||||||
assert_bash_list {"b\\ c a"} $cmd $test
|
assert_bash_list {"b\\ c a"} $cmd $test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user