Closed aik099 closed 8 years ago
Thanks, @aik099. Took a bit to figure this one out. Details are in the commit message, but the gist of it is that stdin gets taken over by the PHP subprocess for some reason on Centos (I was using 6.7 with BASH 4.1). The work around is specifying /dev/null
as the stdin source for PHP.
# Basic completion function: works as expected
function _example_complete {
local cur=${COMP_WORDS[COMP_CWORD]}
local RESULT="apple banana cherry danger will robinson"
COMPREPLY=( $(compgen -W '$RESULT' -- $cur) )
};
# Add a PHP process that does nothing
# Has the stdin take-over/tab characters showing issue
function _example_complete {
php -r ''
local cur=${COMP_WORDS[COMP_CWORD]}
local RESULT="apple banana cherry danger will robinson"
COMPREPLY=( $(compgen -W '$RESULT' -- $cur) )
};
# Give the PHP process /dev/null for stdin
# Works as expected
function _example_complete {
php -r '' </dev/null
local cur=${COMP_WORDS[COMP_CWORD]}
local RESULT="apple banana cherry danger will robinson"
COMPREPLY=( $(compgen -W '$RESULT' -- $cur) )
};
Amazing. Thanks.
I've tested that this solution works for me as well.
I've tried to install auto-completion hook on CentOS, but upon TAB press I see TAB symbol added instead of actual command names of Symfony Console app.
Here are values of hook variables (I've typed
program
and pressed TAB TAB):CMDLINE_CONTENTS: project-tool.phar
(app name + space at the end)CMDLINE_CURSOR_INDEX: 18
CMDLINE_WORDBREAKS: "'><=;|&(:
(also SPACE, TAB and ENTER in front)If I dump these vars on other computer, where auto-completion works, then values are exactly the same.
The result of
_completion
command dumped from hook also seems to be correct: new line separated command names.I have no idea why Bash doesn't use it.
Video of how it works on Slackware (Bash 4.x): http://www.screencast.com/t/cpNRD7oVc Video of how it doesn't work on CentOS (Bash 3.x): http://www.screencast.com/t/sUMgB3j2x