valgrind --tool: Use compgen -W instead of embedding $cur in the sed script.

$cur may contain characters that break the script, for example "/".
This commit is contained in:
Ville Skyttä 2011-11-20 19:43:46 +02:00
parent 811666369e
commit a8218ee1c9

View File

@ -31,10 +31,11 @@ _valgrind()
--tool)
# Tools seem to be named e.g. like memcheck-amd64-linux from which
# we want to grab memcheck.
COMPREPLY=( $( for f in /usr{,/local}/lib{,64}/valgrind/*; do
COMPREPLY=( $( compgen -W '$(
for f in /usr{,/local}/lib{,64}/valgrind/*; do
[[ $f != *.so && -x $f ]] &&
sed -ne "s/^.*\/\($cur.*\)-\([^-]*\)-\([^-]*\)/\1/p" <<<$f
done) )
sed -ne "s/^.*\/\(.*\)-\([^-]*\)-\([^-]*\)/\1/p" <<<$f
done )' -- "$cur" ) )
return
;;
--sim-hints)