Bug 16224

Summary: abnormally behavior of bash
Product: Mageia Reporter: igor ivanov <algaraad>
Component: RPM PackagesAssignee: Shlomi Fish <shlomif>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Normal CC: basesystem, mageia, marja11, shlomif
Version: 6   
Target Milestone: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard: MGA5TOO
Source RPM: bash-4.3-33.1.mga5 bash-completion-2.1-9.mga5 CVE:
Status comment:

Description igor ivanov 2015-06-27 14:40:29 CEST
Description of problem:
when writing a serie of command separated by a line return as separator, only the first command is executed


Version-Release number of selected component (if applicable):


How reproducible:in your .bashrc, type the following alias:
alias echotest1='echo "a"
                 echo "b"
                 echo "c"'
alias echotest2='echo "a"; echo "b"; echo "c"'

when typing in a terminal echotest1, the result will be
a

when typing in a terminal echotest2, the result will be
a
b
c



Steps to Reproduce:
1.kwrire .bashrc
2.type in .bashrc the two alias above
3.close any already opened terminal, open a new terminal and successively type
echotest1
echotest2
and see the result


Reproducible: 

Steps to Reproduce:
Comment 1 igor ivanov 2015-06-27 15:14:03 CEST
but:

alias echotest3='echo "a";
                 echo "b";
                 echo "c"'
alias echotest4='echo "a" &&
                 echo "b" &&
                 echo "c"'

echotest3 gives
a

echotest4 gives
a
b
c
Comment 2 Rémi Verschelde 2015-06-27 15:29:07 CEST
That looks pretty normal shell scripting to me. Do you have a reference that says that Bash should work differently?

Source RPM: bash-4.3-33.1.mga5 bash-completion-2.1-9.mga5 bash-4.3-33.1.mga5 => bash-4.3-33.1.mga5 bash-completion-2.1-9.mga5

Comment 3 igor ivanov 2015-06-27 15:39:18 CEST
(In reply to Rémi Verschelde from comment #2)
> That looks pretty normal shell scripting to me. Do you have a reference that
> says that Bash should work differently?

yes, on my old mageia4, I have not discarded, echotest1 gives
a
b
c

didn't try echotest3
Comment 4 Rémi Verschelde 2015-06-27 15:46:05 CEST
CC'ing bash maintainer.

CC: (none) => shlomif

Comment 5 Shlomi Fish 2015-06-27 16:59:15 CEST
OK, some news:

1. On my default Mageia 6 x86-64 user, all these aliases work fine. OTOH, on Mageia 5 x86-64, I was able to reproduce the offending behaviour. This seems strange to me because Mageia 5 and Mageia 6 carry the same versions of bash, glibc, and coreutils - only with a different kernel.

2. On a new user ("kdetest") on Mageia 5 x86-64, then I get the offending behaviour with the default .bashrc  and .bash_profile and do not get that after I move them away.

3. I'll investigate further.
Comment 6 Shlomi Fish 2015-06-27 17:08:29 CEST
Some more news - I discovered this only happens in Mageia 5 x86-64 if the TERM environment variable is set to "xterm" on Bash's startup. If  you remove it from the environment, then everything is fine.

Regards,

-- Shlomi Fish
Comment 7 Shlomi Fish 2015-06-27 17:17:57 CEST
Apparently ncurses is the same version in Mageia 6 and Mageia 5 too, so I still don't know what is particularly broken on Mageia 5.
Comment 8 Shlomi Fish 2015-06-27 17:31:23 CEST
OK, now I am getting it in a different "kdetest" user on Mageia 6 x86-64 with TERM=screen. so I even more don't know what the problem is now.
Comment 9 Shlomi Fish 2015-06-27 17:58:08 CEST
Here's another thing that I found:

[shlomif@localhost ~]$ echotest1
a
[shlomif@localhost ~]$ unset PROMPT_COMMAND
[shlomif@localhost ~]$ echotest1
a
b
c
[shlomif@localhost ~]$ echotest1

So the problem appears to be with the PROMPT_COMMAND.
Comment 10 igor ivanov 2015-06-28 12:51:55 CEST
congratulations, but the way to keep it permanent?
Comment 11 Shlomi Fish 2015-06-28 13:04:23 CEST
(In reply to igor ivanov from comment #10)
> congratulations, but the way to keep it permanent?

One way is to add "unset PROMPT_COMMAND" to the bottom of your ~/.bashrc . But this is a problem that should be fixed more globally.
Comment 12 igor ivanov 2015-06-28 16:24:22 CEST
(In reply to Shlomi Fish from comment #11)
> (In reply to igor ivanov from comment #10)
> > congratulations, but the way to keep it permanent?
> 
> One way is to add "unset PROMPT_COMMAND" to the bottom of your ~/.bashrc .
> But this is a problem that should be fixed more globally.

it works well, but it's only a patch
Comment 13 Shlomi Fish 2015-11-13 22:36:13 CET
An update: I tested it and the problem disappears if I remove the $(perl ... -e ' ... ') from the PROMPT_COMMAND and persists if it only has this there:

   $(perl -e 'print "Foobar"')

This means we may need to get rid of our use of perl there and replace it with something else.
Samuel Verschelde 2016-11-01 13:26:37 CET

CC: (none) => basesystem
Assignee: bugsquad => shlomif

Comment 14 Marja Van Waes 2018-05-03 08:13:40 CEST
Hi Igor,

Thank you for having taken the needed time to report this issue!

Hi Shlomi,

Thanks for the debugging :-)

@ All:

Did this bug get fixed? If so, please change its status to RESOLVED - FIXED

If it didn't, then we regret that we weren't able to fix it in Mageia 5. Mageia 5 has officially reached its End of Life on December 31st, 2017 https://blog.mageia.org/en/2017/11/07/mageia-5-eol-postponed/
It only continued to get important security updates since then, because we are waiting for a big Plasma5 update in Mageia 6, that'll fix many of the Mageia 5 => 6 upgrade issues.

If you haven't seen that this bug got fixed, then please check whether this bug still exists in Mageia 6. If it does, then please change the Version (near the top, at the left) to "6". If you know it exists in Cauldron, then change Version to Cauldron. If you see it in both Cauldron and Mageia 6, then please set Version to Cauldron and add MGA6TOO on the Whiteboard.

Thanks,
Marja

CC: (none) => marja11

Comment 15 igor ivanov 2018-05-03 14:42:47 CEST
(In reply to Marja Van Waes from comment #14)
> Hi Igor,
> 
> Thank you for having taken the needed time to report this issue!
> 
> Hi Shlomi,
> 
> Thanks for the debugging :-)
> 
> @ All:
> 
> Did this bug get fixed? If so, please change its status to RESOLVED - FIXED
> 
> If it didn't, then we regret that we weren't able to fix it in Mageia 5.
> Mageia 5 has officially reached its End of Life on December 31st, 2017
> https://blog.mageia.org/en/2017/11/07/mageia-5-eol-postponed/
> It only continued to get important security updates since then, because we
> are waiting for a big Plasma5 update in Mageia 6, that'll fix many of the
> Mageia 5 => 6 upgrade issues.
> 
> If you haven't seen that this bug got fixed, then please check whether this
> bug still exists in Mageia 6. If it does, then please change the Version
> (near the top, at the left) to "6". If you know it exists in Cauldron, then
> change Version to Cauldron. If you see it in both Cauldron and Mageia 6,
> then please set Version to Cauldron and add MGA6TOO on the Whiteboard.
> 
> Thanks,
> Marja

this bug is fixed, provided you add to .bashrc the following line:
unset PROMPT_COMMAND
Comment 16 Marja Van Waes 2018-05-03 21:53:09 CEST
(In reply to igor ivanov from comment #15)

> 
> this bug is fixed, provided you add to .bashrc the following line:
> unset PROMPT_COMMAND

That doesn't sound like fixed to me, that sounds like a workaround. Does that line still need to be there when you use Mageia 6, too?

Anyway, in the Cauldron I'm using now, echotest1, 2, 3 and 4 all work as desired, both in Xfce and in a VT (tty3), without needing a workaround
Comment 17 igor ivanov 2018-05-05 14:13:12 CEST
(In reply to Marja Van Waes from comment #16)
> (In reply to igor ivanov from comment #15)
> 
> > 
> > this bug is fixed, provided you add to .bashrc the following line:
> > unset PROMPT_COMMAND
> 
> That doesn't sound like fixed to me, that sounds like a workaround. Does
> that line still need to be there when you use Mageia 6, too?
> 
> Anyway, in the Cauldron I'm using now, echotest1, 2, 3 and 4 all work as
> desired, both in Xfce and in a VT (tty3), without needing a workaround

sorry, but if the line "unset PROMPT_COMMAND" is commented (i.e. disabled)
I get:

[alain4@mageia5_64 ~]$ echotest1
a
[alain4@mageia5_64 ~]$ echotest2
a
b
c
[alain4@mageia5_64 ~]$ echotest3
a
[alain4@mageia5_64 ~]$ echotest4
a
b
c

in both mageia5 & 6
hence the bug is not yet fixed
Comment 18 Nicolas Lécureuil 2018-05-05 17:01:10 CEST
I added the MGA6TOO Keyword.

Btw i tested in cauldron and this is fixed.

CC: (none) => mageia
Whiteboard: (none) => MGA6TOO

Comment 19 Nicolas Lécureuil 2018-05-05 17:23:01 CEST
and i confirm this is broken on mageia 6
Comment 20 Marja Van Waes 2018-07-02 19:34:13 CEST
(In reply to Nicolas Lécureuil from comment #18)
> I added the MGA6TOO Keyword.
> 
> Btw i tested in cauldron and this is fixed.

(In reply to Nicolas Lécureuil from comment #19)
> and i confirm this is broken on mageia 6

Thanks, Nicolas :-)

Changing the version to 6 then, and setting MGA5TOO, because we always set bug reports to the highest affected version ;-)

Whiteboard: MGA6TOO => MGA5TOO
Version: 5 => 6

Comment 21 Lewis Smith 2019-12-02 20:15:57 CET
(In reply to Nicolas Lécureuil from comment #18)
> Btw i tested in cauldron and this is fixed.
Trying on Mageia 7:
 $ cat .bashrc
...
alias echotest='echo "a"
                echo "b"
		echo "c"'
...
 $ echotest
a
b
c

Resolution: (none) => FIXED
Status: NEW => RESOLVED