When backspace becomes ^[[D and up arrow becomes ^[[A
I am using php-shell.sh to try out some php code interactively. However, as is often the case when using command line interactive tools in Linux/bash, the cursor control keys don't work anymore. This is really frustrating if I want to repeat the last command and/or move the cursor around to tweak what I typed in the same way as I am used to doing in a bash shell.
This is not limited to php-shell.sh I am using as an exmaple but also happens when using the read" command in bash.
Is there a way of starting php-shell.sh and similar scripts such that the cursor keys work as expected?
I'm asking here because Google doesn't return any meaning for results when I search for things like ^[[D or ^[[A. Even when I wrap it in quotes.
EDIT. SOLVED.
OK I just found my solutions. For standard bash input, use the "e" swith on a read command to get the arrow keys to work. This causes read to use the readline library.
read -ep "Move t'cursor around, lad!" typedlinevar
For php-shell.sh, it will use the readline library as well if php-readline is installed. This is the name of the rpm package on Mandriva. I guess other distros have something similar.
Now I can us php-shell.sh AND repeat the last command, edit it, etc.
Last edited by simonb; 12-20-2008 at 02:01 AM.
Reason: Solved
|