[Bash-completion-devel] Weirdness when invoking php in a completion function

Ville Skyttä ville.skytta at iki.fi
Mon May 2 18:10:29 UTC 2011


I ran into something weird when php gets invoked inside a completion
function.  For example:

$ bash --norc
$ _php() { COMPREPLY=( $( compgen -W '$( php -h )' -- "$2" ) ); }
$ complete -F _php php

Then, tried completing "php -<TAB>".  All good so far, stuff starting
with - is listed.  But then hit another tab and things go south: no more
completing, hitting tab actually inserts a tab to the console.  The php
invocation doesn't even have to be related to creating the completions,
for example this function shows the same behavior:

_php() {
     php -h &>/dev/null
     COMPREPLY=( $( compgen -W '--foo --bar' -- "$2" ) )

I've never seen this behavior before, and it seems to happen only with
php for me.  And my own system is the only one I see this with:

bash 4.1.7(1)-release, PHP 5.3.6 (Fedora 14)
Ditto with bash 3.2.39(1)-release on the same box.

I cannot reproduce the problem with the following, it works fine with them:

bash 3.2.25(1)-release, php 5.1.6 (CentOS 5.6)
bash 4.1.5(1)-release, php 5.3.3-7+squeeze1 (Debian)
bash 4.2.8(1)-release, php 5.3.6 (Fedora development)

Anyone have ideas what might cause this?

More information about the Bash-completion-devel mailing list