bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: shouldn't prompt printing be smarter?


From: Bob Proulx
Subject: Re: shouldn't prompt printing be smarter?
Date: Sun, 1 Apr 2007 10:41:55 -0600
User-agent: Mutt/1.5.9i

Francesco Montorsi wrote:
>    I think you all have encountered this: do a "cat somefile" where 
> "somefile" is a text file _without_ a final newline. You'll see the 
> prompt is printed both at the end of the text printed by 'cat' and then, 
> also at the beginning of that same line.

I cannot reproduce your reported behavior.  I think there must also be
some interaction with your environment.  I only see the prompt once.

> I'm attaching a screenshot which should make it clear.

What is your PROMPT_COMMAND set to?  If your PROMPT_COMMAND is also
printing out PS1 then that would possibly create the situation that
you describe.  What is your PS1 set to?  Depending upon the values you
have set there that might possibly create the situation that you
describe.

> I think it would be great if bash before printing the prompt could do a 
> simple check: if the cursor is not positioned in the first column of the 
> terminal, then prepend the prompt with a newline.

I think that bash shouldn't try to ask the terminal where the cursor
is because that I believe would react badly on many terminals.

While use of 'cat' as a file dumper is certainly a time honored
tradition it is not the purpose of the program.  The purpose of the
cat program is to concatenate files and it does that exactly without
adding a newline to the end if one does not exist.

To avoid the problem with files without a trailing newline it is
better to use more or less or most or other pagers that are designed
to deal with terminal screens.  Use of cat to browse files is a
power-user mentality that says that you know what you are doing and
are driving the machine at that level.  Therefore when the file does
not have a trailing newline it is expected that you will deal with it.

Bob




reply via email to

[Prev in Thread] Current Thread [Next in Thread]