Bug 1479220 - bash 4.4 changed behavior wrt to builtin 'command'
bash 4.4 changed behavior wrt to builtin 'command'
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: bash (Show other bugs)
26
Unspecified Linux
unspecified Severity unspecified
: ---
: ---
Assigned To: Siteshwar Vashisht
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2017-08-08 02:51 EDT by Reto Zingg
Modified: 2017-08-13 16:53 EDT (History)
3 users (show)

See Also:
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 16:53:45 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Fix value of BUILTIN_FLAG_REQUIRES (705 bytes, patch)
2017-08-08 06:14 EDT, Siteshwar Vashisht
kdudka: review+
Details | Diff

  None (edit)
Description Reto Zingg 2017-08-08 02:51:16 EDT
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 02:53:25 EDT
This is related to bug #1479222
Comment 2 Siteshwar Vashisht 2017-08-08 06:14 EDT
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 06:23:57 EDT
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 06:29:20 EDT
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 07:13:28 EDT
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 00:02:50 EDT
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 16:53:45 EDT
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.

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