View previous topic :: View next topic |
Author |
Message |
potuz Guru

Joined: 30 Jan 2010 Posts: 378
|
Posted: Sun Jul 05, 2015 3:42 pm Post subject: bash strange behaviour printing \n character |
|
|
Using /bin/sh I get the right behavior:
Code: | $ echo "hello\nworld"
hello\nworld
$ echo -e "hello\nworld"
hello
world
$ |
However in bash I get this weird behaviour:
Code: |
$ echo "hello\nworld"
world"hello\nworld
$ echo -e "hello\nworld"
world"hello
world
$ |
However, redirecting the output to a file works fine
Code: | $ echo -e "hello\nworld" > hello.txt && cat hello.txt
world" > hello.txthello
world
$ |
Does anyone know what's going on? |
|
Back to top |
|
 |
John R. Graham Administrator


Joined: 08 Mar 2005 Posts: 10459 Location: Somewhere over Atlanta, Georgia
|
Posted: Sun Jul 05, 2015 4:09 pm Post subject: |
|
|
What is /bin/sh symlinked to? Report the output ofand the output of Code: | set | egrep 'TERM|BASH_VERSION' | please.
For what it's worth, sh and bash behave the same (and apparently correctly) here, which is expected as sh is symlinked to bash.
- John _________________ I can confirm that I have received between 0 and 499 National Security Letters. |
|
Back to top |
|
 |
potuz Guru

Joined: 30 Jan 2010 Posts: 378
|
Posted: Sun Jul 05, 2015 4:22 pm Post subject: |
|
|
John R. Graham wrote: | What is /bin/sh symlinked to? Report the output of
|
Yeah I forgot to say that it's strange cause my default shell is bash!
Code: |
$ ls -ld `which sh`
lrwxrwxrwx 1 root root 4 May 24 07:45 /bin/sh -> bash
|
John R. Graham wrote: |
and the output of Code: | set | egrep 'TERM|BASH_VERSION' | please.
|
Code: |
$ set | egrep 'TERM|BASH_VERSION'
BASH_VERSION='4.3.33(1)-release'
COLORTERM=rxvt-xpm
TERM=rxvt-unicode-256color |
|
|
Back to top |
|
 |
John R. Graham Administrator


Joined: 08 Mar 2005 Posts: 10459 Location: Somewhere over Atlanta, Georgia
|
Posted: Sun Jul 05, 2015 4:28 pm Post subject: |
|
|
Okay, good. So the only difference between your environment and mine is that I'm running konsole but you're running rxvt-unicode, so I'm afraid this is a display artifact bug with rxvt-unicode. Further evidence is that the content of files ends up correct always; in other words, bash works correctly when rxvt-unicode is out of the picture.
- John _________________ I can confirm that I have received between 0 and 499 National Security Letters. |
|
Back to top |
|
 |
John R. Graham Administrator


Joined: 08 Mar 2005 Posts: 10459 Location: Somewhere over Atlanta, Georgia
|
Posted: Sun Jul 05, 2015 11:35 pm Post subject: |
|
|
I've done a little experimentation and have not been able to reproduce your issue. Could you post the output of Code: | emerge -1vp rxvt-unicode | so we can see exactly which USE flags you built with?
- John _________________ I can confirm that I have received between 0 and 499 National Security Letters. |
|
Back to top |
|
 |
potuz Guru

Joined: 30 Jan 2010 Posts: 378
|
Posted: Sat Aug 29, 2015 7:34 pm Post subject: |
|
|
John R. Graham wrote: | I've done a little experimentation and have not been able to reproduce your issue. Could you post the output of Code: | emerge -1vp rxvt-unicode | so we can see exactly which USE flags you built with?
- John |
Sorry for the very long delay in replying, I sort of solved my original problem avoiding this issue. I indeed suspect this is an rxvt-unicode issue. I'll try to post this in their bugzilla.
Code: | $ emerge -1vp rxvt-unicode
[ebuild R ] x11-terms/rxvt-unicode-9.21::gentoo USE="256-color focused-urgency font-styles mousewheel perl pixbuf vanilla xft -alt-font-width -blink -buffer-on-clear -fading-colors -iso14755 -secondary-wheel -startup-notification -unicode3 -wcwidth" 0 KiB
|
|
|
Back to top |
|
 |
Roman_Gruber Advocate

Joined: 03 Oct 2006 Posts: 3806 Location: Austro Bavaria
|
Posted: Sat Aug 29, 2015 7:42 pm Post subject: |
|
|
Code: | roman@Knight ~ $ env|grep bash
SHELL=/bin/bash
roman@Knight ~ $ echo "hello\nworld"
hello\nworld
roman@Knight ~ $ echo -e "hello\nworld"
hello
world |
|
|
Back to top |
|
 |
|