[Bash-completion-devel] replacing _minimal with fallback to bash-builtin

Peter Cordes peter at cordes.ca
Wed Dec 3 19:14:40 UTC 2014


I've been playing around with having _completion_loader() do

compopt -o bashdefault -o default

instead of 

# Need to define *something*, otherwise there will be no completion at all.
#    complete -F _minimal -- "$cmd" && return 124


 Then I can always prefix my command with a \ to get built-in style
completion where bash_completion doesn't do a good job.  e.g. doesn't
expand args of commands inside $(command substitution), or
ls $HOME/[TAB] => \$HOME/
And you get
asdfasdf /s*[TAB] => sbin/ srv/  swap/ sys/  instead of
ls /s*[TAB] => nothing

 Even if the behaviour was identical for commands without special
completion handling, this way doesn't lead to an ever-growing hash
table of complete functions and cluttered complete -p results. 

 And it's presumably faster.  Even _minimal does the whole loop over
words up to the completion word.  (I'm still not sure of everything
that that accomplishes...  _get_comp_words_by_ref() has a comment
saying that it's nicer than ${COMP_WORDS[$COMP_CWORD]} in case the
point is in the middle of a word to be completed, but AFAICT it
behaves identically in that respect.)  Are there any design docs for
this stuff?  I've followed the code vs. set -x output, and I've
followed some of what it does, but I still don't understand why.

 Anyway, right now I don't think progcomp offers any advantage over
bash builtin when we don't have a specific completion function, and
due to bugs and shortcomings (that will hopefully be fixed), it's worse.

 The main argument against this change would be consistency of user
experience, I guess.  "Why does $(cat ./[TAB] only work some of the
time?" would be one thing you'd see users confused about.

 Anyway, that's what I'm doing for my own use, because I know what's
going on.

-- 
#define X(x,y) x##y
Peter Cordes ;  e-mail: X(peter at cor , des.ca)

"The gods confound the man who first found out how to distinguish the hours!
 Confound him, too, who in this place set up a sundial, to cut and hack
 my day so wretchedly into small pieces!" -- Plautus, 200 BC
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 359 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/bash-completion-devel/attachments/20141203/dcc11039/attachment.sig>


More information about the Bash-completion-devel mailing list