Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
bash strange behaviour printing \n character
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
potuz
Guru
Guru


Joined: 30 Jan 2010
Posts: 378

PostPosted: Sun Jul 05, 2015 3:42 pm    Post subject: bash strange behaviour printing \n character Reply with quote

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
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 10157
Location: Somewhere over Atlanta, Georgia

PostPosted: Sun Jul 05, 2015 4:09 pm    Post subject: Reply with quote

What is /bin/sh symlinked to? Report the output of
Code:
ls -ld `which sh`
and 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
View user's profile Send private message
potuz
Guru
Guru


Joined: 30 Jan 2010
Posts: 378

PostPosted: Sun Jul 05, 2015 4:22 pm    Post subject: Reply with quote

John R. Graham wrote:
What is /bin/sh symlinked to? Report the output of
Code:
ls -ld `which sh`


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
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 10157
Location: Somewhere over Atlanta, Georgia

PostPosted: Sun Jul 05, 2015 4:28 pm    Post subject: Reply with quote

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
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 10157
Location: Somewhere over Atlanta, Georgia

PostPosted: Sun Jul 05, 2015 11:35 pm    Post subject: Reply with quote

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
View user's profile Send private message
potuz
Guru
Guru


Joined: 30 Jan 2010
Posts: 378

PostPosted: Sat Aug 29, 2015 7:34 pm    Post subject: Reply with quote

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
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3806
Location: Austro Bavaria

PostPosted: Sat Aug 29, 2015 7:42 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum