Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 12-20-2008, 01:47 AM   #1
LQ Newbie
Registered: Dec 2002
Posts: 11

Rep: Reputation: 0
When backspace becomes ^[[D and up arrow becomes ^[[A

I am using 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 I am using as an exmaple but also happens when using the read" command in bash.

Is there a way of starting 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.

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, 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 AND repeat the last command, edit it, etc.

Last edited by simonb; 12-20-2008 at 02:01 AM. Reason: Solved
Old 12-21-2008, 01:04 AM   #2
LQ Guru
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

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

debian@Christmas $: info bash


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash case with arrow keys (and DEL, BACKSPACE,etc) sadarax Programming 11 02-15-2012 11:15 AM
Shift-arrow and Alt-arrow keys don't work in xterm Aviv Hurvitz Linux - General 2 09-30-2006 03:43 PM
Shortcut arrow thort Mandriva 0 11-04-2004 03:28 PM
down arrow key problem rcbob Linux - Software 0 06-05-2004 07:58 PM
C : Can't type right arrow aditya Programming 4 02-15-2003 07:45 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:01 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration