note 117110 added to function.readline-completion-function

From: Date: Thu, 16 Apr 2015 03:37:00 +0000
Subject: note 117110 added to function.readline-completion-function
Groups: php.notes 
Request: Send a blank email to php-notes+get-202278@lists.php.net to get a copy of this message
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. ---- Server IP: 72.52.91.14 Probable Submitter: 103.5.73.3 ---- Manual Page -- http://php.net/manual/en/function.readline-completion-function.php Edit -- https://master.php.net/note/edit/117110 Del: integrated -- https://master.php.net/note/delete/117110/integrated Del: useless -- https://master.php.net/note/delete/117110/useless Del: bad code -- https://master.php.net/note/delete/117110/bad+code Del: spam -- https://master.php.net/note/delete/117110/spam Del: non-english -- https://master.php.net/note/delete/117110/non-english Del: in docs -- https://master.php.net/note/delete/117110/in+docs Del: other reasons-- https://master.php.net/note/delete/117110 Reject -- https://master.php.net/note/reject/117110 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#202278) next »