Bug 1010761 - type command output function, Inconsistent with the function definition.
Summary: type command output function, Inconsistent with the function definition.
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: bash
Version: 7.0
Hardware: All
OS: Linux
high
unspecified
Target Milestone: rc
: ---
Assignee: Ondrej Oprala
QA Contact: BaseOS QE - Apps
URL:
Whiteboard:
Depends On: 1010759
Blocks: 1010760
TreeView+ depends on / blocked
 
Reported: 2013-09-23 02:15 UTC by JianHong Yin
Modified: 2014-02-21 14:44 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of: 1010759
Environment:
Last Closed: 2014-02-21 14:44:53 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description JianHong Yin 2013-09-23 02:15:04 UTC
+++ This bug was initially created as a clone of Bug #1010759 +++

Description of problem:
type command output  function, Inconsistent with the function definition.

Version-Release number of selected component (if applicable):
[root@dhcp-13-194 ~]# rpm -q bash
bash-3.2-32.el5; in RHEL6.4 6.5 7.0 has the similar problem.

How reproducible:
100%

Steps to Reproduce:
1. f() { echo $1 | grep --color=auto  "kkk"; rm -i kkk; }
2. type f
3.

Actual results:
[root@dhcp-13-194 ~]# f() { echo $1 | grep --color=auto  "kkk"; rm -i kkk; }
[root@dhcp-13-194 ~]# type f
f is a function
f () 
{ 
    echo $1 | grep --color=auto "kkk";
    rm -i -i kkk  <<<--- here the '-i' was changed to double
}

Expected results:


Additional info:

Comment 1 JianHong Yin 2013-09-23 02:16:33 UTC
test in RHEL7

[root@dhcp12-185 ~]# f() { echo $1 | grep --color=auto  "kkk"; rm -i kkk; }
[root@dhcp12-185 ~]# type f
f is a function
f () 
{ 
    echo $1 | grep --color=auto --color=auto "kkk";  <<<--- here --color double
    rm -i -i kkk  <<<--- and here -i double
}
[root@dhcp12-185 ~]# rpm -q bash
bash-4.2.45-1.el7.x86_64

Comment 3 Ondrej Oprala 2013-10-16 12:19:29 UTC
Unable to reproduce with bash-4.2.45-2.el7. Are you sure this problem persists in RHEL7?

Comment 4 JianHong Yin 2013-10-17 09:34:18 UTC
(In reply to Ondrej Oprala from comment #3)
> Unable to reproduce with bash-4.2.45-2.el7. Are you sure this problem
> persists in RHEL7?

Test in bash-4.2.45-1.el7.x86_64

[root@dhcp12-185 ~]# f() { echo $1 | grep --color=auto  "kkk"; rm -i kkk; }
[root@dhcp12-185 ~]# type f
f is a function
f () 
{ 
    echo $1 | grep --color=auto --color=auto "kkk";  <<<--- here --color double
    rm -i -i kkk  <<<--- and here -i double
}

[root@dhcp12-185 ~]# rpm -q bash
bash-4.2.45-1.el7.x86_64  <<<---

Comment 5 JianHong Yin 2014-01-06 10:04:59 UTC
[yjh@dhcp12-241 ~]$ /usr/bin/bash
[yjh@dhcp12-241 ~]$ f() { echo $1 | grep --color=auto  "kkk"; rm -i kkk; }
[yjh@dhcp12-241 ~]$ type f
f is a function
f () 
{ 
    echo $1 | grep --color=auto --color=auto "kkk";
                        <<<--- here --color double still ...
    rm -i kkk
}
[yjh@dhcp12-241 ~]$ rpm -q bash
bash-4.2.45-3.el7.x86_64

Comment 6 Ondrej Oprala 2014-02-21 14:44:53 UTC
Petr Stodulka investigated this bug and found out this is actually caused by alias expansion.
I'm guessing you have an alias rm='rm -i' set, which bash then expands to 'rm -i -i'; which I do not consider a bug.

Please note it's a good coding habit to specify full paths for system utilities in shell scripts, which would also stop bash from silently expanding your alias.


Note You need to log in before you can comment on or make changes to this bug.