LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices


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

Rep: Reputation: 0
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
 
Old 12-21-2008, 01:04 AM   #2
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,513

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

debian@Christmas $: info bash
 
  


Reply


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

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:07 AM.

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