В сообщении от 6 июня 2011 23:59:44 автор Ville Skyttä написал: > > kcov: New completion > > [...] > > > + if [[ "$cur" == -* ]]; then > > + COMPREPLY=( $( compgen -W '$( _parse_help "$1" --help )' -- > > "$cur" ) ) + [[ $COMPREPLY == *= ]] && compopt -o nospace > > + return 0 > > + fi > > Just a minor nit: the above block of code would be better placed after > option argument completions (i.e. the "case $prev" block and $split && > return 0), otherwise bogus completions are produced for option argument > completions starting with a dash, for example "kcov --pid=-<TAB>" > (guesswork, I don't have kcov installed or available as a package).
This is sane, thanks. I'll take your advice. But I have a suggestion. To make completions more correct, after setting COMPREPLY, we can check if some reply is found, and if not, we can go to default path. Like this: _installpkg() { local cur prev words cword _init_completion || return case "$prev" in --root) _filedir -d return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--warn --root' -- "$cur") ) - return + [[ ${#COMPREPLY[@]} -gt 0 ]] && return fi _filedir "t[bglx]z" } && complete -F _installpkg installpkg This way this function will allow to complete an awful file name like "-- xo.txz". Is that good thing to do? _______________________________________________ Bash-completion-devel mailing list Bash-completion-devel@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/bash-completion-devel