Bug 1479220

Summary: bash 4.4 changed behavior wrt to builtin 'command'
Product: [Fedora] Fedora Reporter: Reto Zingg <g.d0b3rm4n>
Component: bashAssignee: Siteshwar Vashisht <svashisht>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 26CC: admiller, kdudka, svashisht
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: bash-4.4.12-7.fc26 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-13 20:53:45 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Fix value of BUILTIN_FLAG_REQUIRES kdudka: review+

Description Reto Zingg 2017-08-08 06:51:16 UTC
Description of problem:

In bash 4.4 the behavior changed with respect to builtin command 'command', called with /bin/sh.


While in bash 4.3 the following works:

    # /bin/sh --version
    GNU bash, version 4.3.43(1)-release (x86_64-redhat-linux-gnu)
    Copyright (C) 2013 Free Software Foundation, Inc.

License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>


    This is free software; you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.
    # /bin/sh -c 'command(){ echo FOO;}; command'
    FOO
    #


It does not work any more in bash 4.4:

    # /bin/sh --version
    GNU bash, version 4.4.12(1)-release (x86_64-redhat-linux-gnu)
    Copyright (C) 2016 Free Software Foundation, Inc.

License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>


    This is free software; you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.
    # /bin/sh -c 'command(){ echo FOO;}; command'
    /bin/sh: `command': is a special builtin
    #


Version-Release number of selected component (if applicable):
bash-4.4.12-6.fc26.x86_64


Additional info:
I reported the same in bash-bug mailing list:
http://lists.gnu.org/archive/html/bug-bash/2017-08/msg00012.html

Answer:
When in Posix mode, bash doesn't allow functions to be defined with the
same name as a special builtin. It seems like RedHat added `command' to
the list of special builtins in their custom build of bash-4.4. Open a
ticket if they're your vendor.
(http://lists.gnu.org/archive/html/bug-bash/2017-08/msg00014.html)

Comment 1 Reto Zingg 2017-08-08 06:53:25 UTC
This is related to bug #1479222

Comment 2 Siteshwar Vashisht 2017-08-08 10:14:54 UTC
Created attachment 1310503 [details]
Fix value of BUILTIN_FLAG_REQUIRES

I used incorrect value for BUILTIN_FLAG_REQUIRES while rebasing to bash-4.4. This patch fixes it.

Comment 3 Kamil Dudka 2017-08-08 10:23:57 UTC
You can make the script portable across various versions of bash using the following command:

    enable -n command

Unfortunately, the above command is specific to bash.  So you would need to run it conditionally to keep the script portable across other shells, too.

Comment 4 Kamil Dudka 2017-08-08 10:29:20 UTC
Comment on attachment 1310503 [details]
Fix value of BUILTIN_FLAG_REQUIRES

Thanks!  It explains why I was not able to reproduce the bug with upstream bash.

Comment 5 Fedora Update System 2017-08-08 11:13:28 UTC
bash-4.4.12-7.fc26 has been submitted as an update to Fedora 26. https://bodhi.fedoraproject.org/updates/FEDORA-2017-2b91680b10

Comment 6 Fedora Update System 2017-08-13 04:02:50 UTC
bash-4.4.12-7.fc26 has been pushed to the Fedora 26 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-2b91680b10

Comment 7 Fedora Update System 2017-08-13 20:53:45 UTC
bash-4.4.12-7.fc26 has been pushed to the Fedora 26 stable repository. If problems still persist, please make note of it in this bug report.