Closed aik099 closed 8 years ago
Try this one?
source <([program] _completion -g)
On README.md it's told that it works only on Bash 4, so I haven't tried.
If I run this, then instead of proper auto-complete I get program
word (the used program name) added on each TAB press.
The version numbers are kind of best guesses as it seems to vary system to system which ones actually work.
It sounds like the hook might be working, but maybe something else isn't; it wouldnt be doing anything if the hook didn't register. Have you tried dumping the CMDLINE_CONTENTS
and cursor variables in the hook code?
Without hook pressing TAB shows files in current folder. So hook definitely working and fact, that it's telling program
as possible auto-complete result sounds like a bug in it.
I've tried to write down generate hook to the file to see what's wrong with it. And I've found that 2nd line contains this:
Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings.
I guess according to PHP settings:
Same error is then present in list of auto-completed values returned from application to the bash.
Regardless to that the _completion
command must do ini_set('display_errors', 'off')
when:
Now I have this returned instead of auto-completed values:
-bash: _get_comp_words_by_ref: command not found
Google tells, that I might have bash_completion
not installed. Here I'd suggest checking for that and returning nice error back (at hook invocation, not generation time) to user so that that he'll know what to do.
Ah right, that makes sense. Nice find. Might need to play around with that fix you're suggesting so that it doesn't hide any other errors inadvertently.. Im not at a computer right now to check, but isn't that date/timezone error printed quite early on in execution?
It'd be nice not to have the dependency on the bash-completion package (see #36), but it means we'll need another way around allowing colons in completion results (that's all it's used for). Will happily accept a PR for a nicer notice as a temporary measure though.
Ah right, that makes sense. Nice find. Might need to play around with that fix you're suggesting so that it doesn't hide any other errors inadvertently..
It's the opposite I've suggested: hide any PHP notices/warnings when _complete
command runs in any form (e.g. hook generation, completion preparation).
Im not at a computer right now to check, but isn't that date/timezone error printed quite early on in execution?
Yes, it's first thing that is printed. Even before function ...
line, where completion function is defined.
It'd be nice not to have the dependency on the bash-completion package (see #36), but it means we'll need another way around allowing colons in completion results (that's all it's used for).
We can't add it as a dependency, because we also support ZSH.
Will happily accept a PR for a nicer notice as a temporary measure though.
Do you know how to check if that Bash function is defined?
@aik099 - The date_default_timezone_get
function isn't used in this library or any of its dependencies. Is your application using it in this case (anywhere in the bootstrap process would cause this).
Also, what PHP version does this system run?
Is your application using it in this case (anywhere in the bootstrap process would cause this).
Yes, the application use date_default_timezone_get
function.
Also, what PHP version does this system run?
5.3.26
I've created #58 PR with check for installed bash-completion
package before defining hook in Bash.
Since date_default_timezone_get
is called during application initialization, but before the CompletionCommand
constructor we don't have any power to alter error reporting setting from there. I suggest we just ignore this use case (when date.timezone
setting wasn't set in PHP).
Thanks, @aik099. I agree that other than flagging it in the docs, there's not much that can be done for the warning issue. I've merged your PR with a small tweak to the message.
Used installation methods:
The 1st method:
/dev/stdin
(not sure if that was expected)program
(space at the end) and pressTAB
theprogram
is auto-completed instead of command namesThe 2nd method:
Output of
bash --version
:P.S. The installation method proposed by
program help _completion
command doesn't work at all: