LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   When backspace becomes ^[[D and up arrow becomes ^[[A (https://www.linuxquestions.org/questions/linux-software-2/when-backspace-becomes-%5E%5B%5Bd-and-up-arrow-becomes-%5E%5B%5Ba-691845/)

simonb 12-20-2008 01:47 AM

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.

AwesomeMachine 12-21-2008 01:04 AM

Just so everyone knows, this is covered in the info for bash:

debian@Christmas $: info bash


All times are GMT -5. The time now is 12:31 PM.