Edit report at http://bugs.php.net/bug.php?id=53040&edit=1
ID: 53040 User updated by: myselfasunder at gmail dot com Reported by: myselfasunder at gmail dot com Summary: PHP crash/failure when called from bash-completion -Status: Open +Status: Closed Type: Bug Package: CGI related Operating System: Ubuntu PHP Version: 5.3.3 Block user comment: N Private report: N New Comment: Even the existence of a PHP call in a bash_completion.d script or any referenced Bash script may cause a complete completion failure, even when all STDERR and STDOUT output is suppressed (redirected to /dev/null), depending on what row it's effectively referenced from in the top-most bash_completion.d script. From what little material there is about this on the Internet, it appears that this problem might be a result of particular Ubuntu versions. No matter. Bash completion with PHP works fine when used with the CGI variant. For example: > /etc/bash_completion.d/foo (Extends example at http://www.debian-administration.org/article/An_introduction_to_bash_completion_part_2) ============================ _foo() { local cur opts COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" SAVE_IFS=$IFS IFS="," BUFFER="${COMP_WORDS[*]}" IFS=$SAVE_IFS opts=`echo "$COMP_CWORD:$BUFFER" | /tmp/completiontest.php` if [[ ${cur} == -* ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) return 0 fi } complete -F _foo foo > /tmp/completiontest.php ========================= #!/usr/bin/php5-cgi -q <?php // Just to 1) prevent writing to the bash_completion.d directory, and // 2) nail-down where our output file, below, will end up. chdir(dirname(__FILE__)); // Grab completion information from STDIN. // Ex: // dustin@mx4:~$ foo --arg1 --arg2 --to_be_complet<TAB>^C // dustin@mx4:~$ cat /tmp/stdin.txt // 3:foo,--arg1,--arg2,--to_be_complet // // Format of received STDIN information is "<number of tokens>:<comma-sep list of tokens>" file_put_contents('stdin.txt', file_get_contents('php://stdin')); // Output the space-separated completion possibilities. print("--abc --def"); Previous Comments: ------------------------------------------------------------------------ [2010-10-11 03:10:44] myselfasunder at gmail dot com Description: ------------ Calling PHP shell-scripts in any way (even if it doesn't do anything) from a bash-completion script causes the bash-completion script to fail (pressing TAB causes erratic spacing and tabbing at the console rather than producing options for completion). Bash and Perl calls work fine. This refers to calling PHP in any of the following ways: o php -r '..' o php script.php o ./script.php (this references '/usr/bin/php' with a shebang at the top) I even tried calling Perl from the Bash, and then calling PHP from the Perl. No change in behavior. I tried with both 5.2 and the latest version of 5.3 . Test script: --------------- No test script necessary. Executing "php -r ''" in a bash completion script causes the failure. Contents of ~/completiontest can be found at: http://www.randomingenuity.com/phpbugreference/20101010-2054_completiontest.php You can commit this to the current bash-completion configuration by executing: ~$ . completiontest To test without PHP, just comment-out the PHP call. Expected result: ---------------- dustin@ubuntu:~$ . completiontest dustin@ubuntu:~$ completiontest --<TAB><TAB> --help --verbose --version dustin@ubuntu:~$ completiontest -- Actual result: -------------- dustin@ubuntu:~$ . completiontest dustin@ubuntu:~$ completiontest -- |<-- Cursor moves to here. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=53040&edit=1
