The readline extension can be a bit flakey due to bugs in libedit (PHP 5.3.10-1ubuntu3.15 with Suhosin-Patch (cli) (built: Oct 29 2014 12:19:04)).
I created many segfaults returning an empty array on the autocompletion function:
// Autocomplete
readline_completion_function(function($Input, $Index){
global $Commands;
// Filter Matches
$Matches = array();
foreach(array_keys($Commands) as $Command)
if(stripos($Command, $Input) === 0)
$Matches[] = $Command;
return $Matches;
});
I found adding an empty string to the matches array prevents the segfault:
// Autocomplete
readline_completion_function(function($Input, $Index){
global $Commands;
// Filter Matches
$Matches = array();
foreach(array_keys($Commands) as $Command)
if(stripos($Command, $Input) === 0)
$Matches[] = $Command;
// Prevent Segfault
if($Matches == false)
$Matches[] = '';
return $Matches;
});
Hopefully this is helpful to someone.