Skip to content

Commit c7b9c45

Browse files
committed
Prevent PHP process taking over stdin during completion on Centos 6
On a fresh install of Centos 6.7 with the default repositories bash and php-cli packages installed (BASH 4.1.2, PHP 5.3.3), attempting to use completion after registering it results in tab characters being added to stdin rather than the expected completion results. The tab characters can be deleted with backspace, however the input before pressing tab cannot - as if it's in another stream. After a bit of fiddling, I've determined that the during the completion hook, the PHP process running completion takes over or at least interferes with stdin for the user's shell, causing the tab key presses to be rendered rather than interpreted. This odd behaviour can be worked around by setting stdin for the PHP process to something specific. I've used /dev/null here, though I'm not 100% sure of its compatibility. Simple test cases: ```bash function _example_complete { local cur=${COMP_WORDS[COMP_CWORD]} local RESULT="apple banana cherry danger will robinson" COMPREPLY=( $(compgen -W '$RESULT' -- $cur) ) }; function _example_complete { php -r '' # run PHP and do nothing local cur=${COMP_WORDS[COMP_CWORD]} local RESULT="apple banana cherry danger will robinson" COMPREPLY=( $(compgen -W '$RESULT' -- $cur) ) }; function _example_complete { php -r '' </dev/null # run PHP and do nothing, specifying stdin as a file local cur=${COMP_WORDS[COMP_CWORD]} local RESULT="apple banana cherry danger will robinson" COMPREPLY=( $(compgen -W '$RESULT' -- $cur) ) }; ``` I haven't tested further to figure out if this is a problem with BASH or with the PHP package on Centos 6, but since the issue doesn't occur under ZSH, I suspect it's a problem with readline/BASH. Fixes #57
1 parent 0e42611 commit c7b9c45

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/HookFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function %%function_name%% {
4141
4242
local RESULT STATUS;
4343
44-
RESULT="$(%%completion_command%%)";
44+
RESULT="$(%%completion_command%% </dev/null)";
4545
STATUS=$?;
4646
4747
local cur;

0 commit comments

Comments
 (0)