LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 11-29-2003, 03:39 PM   #1
monkeyman2000
Member
 
Registered: Oct 2003
Posts: 68

Rep: Reputation: 15
bash does not wrap long lines correctly


Hi,

bash is my default shell. When I type a long command line in a terminal, it does not wrap to the next line when I reach the end of the line... instead it wraps onto the same line, overwriting my prompt and the resf of what I typed. The commands still work, but it's obviously very inconvenient not to be able to correctly see what you are typing.

If I switch to sh as my shell instead (by typeing sh), the command lines wrap correctly. But I don't want to use sh.

If I switch the TERM environmental variable from xterm to vt100, the command lines wrap correctly. But this causes problems with other applications, notably vim.

The problem occurs in all the graphical terminals (xterm, konsole, gnome-terminal, rxvt, etc), though not when I am not using X (and TERM is set to vt100).

Can anyone tell me how to get the bash shell to wrap long lines to the next line correctly? It may be a matter of setting TERM to something other than xterm, but I am not very familar with terminfo and how all that works.

Thanks so much for any help you can provide!!


My system:
RedHat 9.0
bash-2.05b-20.1
/etc/termcap Version 10.2.1
 
Old 11-29-2003, 08:58 PM   #2
gernt
LQ Newbie
 
Registered: Nov 2003
Location: Crossville, Tennessee
Distribution: RedHat 9
Posts: 26

Rep: Reputation: 15
I'm a little confused. I gather you aren't talking about the monitor but other boxes running an x-terminal emulator like MI/X? Or are you saying this happens when you open a terminal screen on the monitor?
 
Old 11-29-2003, 09:46 PM   #3
monkeyman2000
Member
 
Registered: Oct 2003
Posts: 68

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by gernt
I'm a little confused. I gather you aren't talking about the monitor but other boxes running an x-terminal emulator like MI/X? Or are you saying this happens when you open a terminal screen on the monitor?
I'm not familiar with MI/X, but let me clarify the problem.

When I type a long command line at the command prompt within an xterm, it should wrap to the next line, like this:

[my prompt]$ ls -l file1 file2 file3 file4 file5 file6 file7 fi
le8 file9


Instead, what happens is this:

le8 file9]$ ls -l file1 file2 file3 file4 file5 file6 file7 fi


See? Instead of wrapping to the next line, the part of the command that exceeds the length of the line starts from the begining of the CURRENT line, overwriting the prompt and what I've typed.

It only happens in xterminals of various types, logged into my local computer (from programs like xterm, rxvt, konsole, gnome-terminal, etc.) . It does not happen on the console before I start xwindows.

Please let me know how to fix this problem if you know. Thank you.
 
Old 11-30-2003, 09:05 AM   #4
gernt
LQ Newbie
 
Registered: Nov 2003
Location: Crossville, Tennessee
Distribution: RedHat 9
Posts: 26

Rep: Reputation: 15
OK, I gather you have xterminals and not Windows computers emulating xterminals. That was my question. I haven't seen a regular xterminal in some time. I tried, but I could not replicate it. But I don't have a vanilla xterminal. I've certainly seen the problem when scrolling is not set right on one end or another. Did it ever work - say on a prior revision? Or is this a brand new setup.
 
Old 11-30-2003, 11:21 AM   #5
gernt
LQ Newbie
 
Registered: Nov 2003
Location: Crossville, Tennessee
Distribution: RedHat 9
Posts: 26

Rep: Reputation: 15
Another thought. What does the command stty produce (maybe nothing)? Try doing an stty ocrnl.

Does the same overwrite happen when the server is sending you something? i.e. Try typing a long nonsense line and hit enter.

Last edited by gernt; 11-30-2003 at 11:23 AM.
 
Old 11-30-2003, 02:35 PM   #6
SharpyWarpy
Member
 
Registered: Feb 2003
Location: Florida
Distribution: Fedora 18
Posts: 862

Rep: Reputation: 90
I had this question a little while back. Put a backward slash and hit enter, then start your long command line.
 
Old 11-30-2003, 02:37 PM   #7
monkeyman2000
Member
 
Registered: Oct 2003
Posts: 68

Original Poster
Rep: Reputation: 15
OK, I think I have figured it out.

I was setting a colored prompt in my .bashrc like this:


GREEN='\[\033[1;32m\]'
NC='\[\033[0m\]'
PS1="[\u@${GREEN}\h${NC} \W]\$ "

unfortuately I had been setting the color values incorrectly (the values above are the correct ones). I had not been terminating the sequences of non-printing characters correctly, and I believe this is what caused the line wrapping to fail.
 
Old 11-30-2003, 07:50 PM   #8
gernt
LQ Newbie
 
Registered: Nov 2003
Location: Crossville, Tennessee
Distribution: RedHat 9
Posts: 26

Rep: Reputation: 15
I got so balled up in trying to keep all the initial scripts together, I moved them to /usr/local/etc. The .bash_motd, .bashrc, etc. in the users area just call the ones in /usr/local/etc. Then, if I make a change, everybody gets changed.

Congratulations. At least one got solved today.
 
Old 09-08-2004, 09:30 PM   #9
{-_-}
LQ Newbie
 
Registered: Jul 2004
Location: Houston, Tx
Distribution: SUSE 9.0 Professional
Posts: 17

Rep: Reputation: 0
prompt

You're correct, terminating the sequence is what causes the lines to wrap incorrectly. I had this same problem on my box, and spent 5 hours or so last nite researching it until I found http://www-106.ibm.com/developerwork.../l-tip-prompt/ .A very good tutorial on the setting your prompt to different colors, written by the creator of gentoo.
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to grep similar lines in bash? bruno buys Linux - Software 2 12-02-2005 11:56 PM
Line wrap errors with ssh / xterm / bash and up-arrow to edit brycen Linux - Software 0 09-22-2004 06:01 PM
Can't get lines of a file with a Bash script.. barisdemiray Programming 2 08-11-2004 12:42 PM
Samba 3.0.2 not mangling long names correctly for Win95/98 JLindenmuth Linux - Networking 0 03-25-2004 01:28 PM
[bash] remove lines from a file Drimo Programming 3 03-20-2004 11:16 AM


All times are GMT -5. The time now is 02:49 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration