[Bash-completion-devel] [SCM] bash-completion branch, master, updated. 1.90-50-g834379e

Igor Murzov e-mail at date.by
Sun Nov 20 00:45:56 UTC 2011


>   # Tools seem to be named e.g. like memcheck-amd64-linux from which
>   # we want to grab memcheck; the same dir may contain things like
>   # default.supp, vgpreload_*.so etc which we want to skip.
>   # TODO: probably needs adjustment to be more generic
>   COMPREPLY=( $( compgen -W "$( \
>       command ls -1 /usr{,/local}/lib{,64}/valgrind 2>/dev/null | \
>       sed -e '/\.so$/d' -ne 's/^\(.*\)-\([^-]*\)-\([^-]*\)/\1/p' )" \
>       -- "$cur" ) )
>   return

This works bad for me. Even *.so files are not deleted, because ls shows them with '*' like "vgpreload_core-x86-linux.so*". That's what completion shows for --tool for me:

------------------------------------------
$ valgrind --tool=
32bit-core                    exp-sgcheck
32bit-linux                   helgrind
32bit-sse                     i386
64bit-core                    lackey
64bit-linux                   libcoregrind
64bit-sse                     libreplacemalloc_toolpreload
amd64                         libvex
arm                           massif
arm-core                      memcheck
arm-vfpv3                     none
arm-with                      power-altivec
cachegrind                    power-fpu
callgrind                     power-linux
drd                           power64-core
exp-bbv                       power64-linux
exp-dhat                      powerpc 
------------------------------------------

What about something like this?:
------------------------------------------
$ for f in /usr{,/local}/lib{,64}/valgrind/*; do
    [[ -x "$f" && "$f" != *.so ]] && echo "$f" | sed -ne 's/^.*\/\(.*\)-\([^-]*\)-\([^-]*\)/\1/p'
done
cachegrind
callgrind
drd
exp-bbv
exp-dhat
exp-sgcheck
helgrind
lackey
massif
memcheck
none
------------------------------------------


>    # "yes", "yes|no", etc (but not "string", "STR",
>    # "hint1,hint2,...")
>    yes|+([a-z0-9])\|+([a-z0-9\|]))

What about dash? Line like this "--smc-check=none|stack|all|all-non-file" is not parsed properly.

>    # Note: intentionally using COMP_WORDS and COMP_CWORD instead of
>    # words and cword here due to splitting on = causing index differences

But using COMP_WORDS directly will brake for any argument, that contains
character from COMP_WORDBREAKS, for example for --log-socket=ipaddr:port.


-- Igor



More information about the Bash-completion-devel mailing list