Hi Bob,
thanks for looking into this!
Bob Proulx ha scritto:
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.
interesting. I've always seen that problem since I started using Linux
some year ago and finally decided today to report it. I always thought
it was a known issue not classified as "bug" or something similar.
I'm attaching a screenshot which should make it clear.
What is your PROMPT_COMMAND set to?
PROMPT_COMMAND='echo -ne "\033]0;${PWD/$HOME/~}\007"'
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?
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;[EMAIL PROTECTED]:\[\033[01;34m\]\w\[\033[00m\]\$
'
what is it btw?
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.
ok, but this problem does not only happen with "cat". It happens with
_any_ program which does not print a newline:
if test.c is:
#include <stdio.h>
int main()
{
printf("Hello world without final newline");
return 0;
}
then:
[EMAIL PROTECTED]:~$ gcc -o test test.c
[EMAIL PROTECTED]:~$ ./test
[EMAIL PROTECTED]:~$ thout final [EMAIL PROTECTED]:~$
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
same weird behaviour I see when using cat with non-newline-ended files.
Interestly, if the main() just returns 0 and does not printf() anything,
then the prompt is correctly printed...
Francesco
_______________________________________________
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash