command line - PHP interactive CLI: Up and Down arrows for history -
i having bug involving php interactive cli program.
i add commands history using readline_add_history, , read them in using readline.
the bug if, using arrow key, scroll through history command 5 characters or longer, first character of command "sticks", , stay there, after keep using arrow keys scroll again. disappears after hit enter.
eg:
% hello <enter> % <up arrow key> % hello <down arrow key> % h <up arrow key> % hhello <down arrow key> % h <enter> % <up arrow key> % hello ** notice here h isn't read in command. **
where can view code involving arrow keys / command history? i've looked online resources on how readline handles arrow keys , history can't find anything.
my code this:
while(true) { $command = readline( "\n%" ); .. stuff .. readline_add_history( $command ); }
i have readline_completion_function isn't being called when use arrow keys.
there seems bug readline() , prompt field (tested php 5.5.9 ubuntu), if prompt field has 'non-printable' characters in it, \n, have used.
i having similar problems, when trying used esc codes color prompt, causes history function go haywire :(
example: $_command = readline("\033[32m php> \033[35m");
the prompt can have normal chars in it, if want history function work correctly, unfortunately.
Comments
Post a Comment