Bug 1479220 - bash 4.4 changed behavior wrt to builtin 'command'
Summary: bash 4.4 changed behavior wrt to builtin 'command'
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: bash
Version: 26
Hardware: Unspecified
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Siteshwar Vashisht
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-08-08 06:51 UTC by Reto Zingg
Modified: 2017-12-05 08:45 UTC (History)
3 users (show)

Fixed In Version: bash-4.4.12-7.fc26
Clone Of:
Environment:
Last Closed: 2017-08-13 20:53:45 UTC
Type: Bug
Embargoed:


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


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1520811 0 unspecified CLOSED Update to bash-4.4.12-7 breaks fish prompt 2021-02-22 00:41:40 UTC

Internal Links: 1520811

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.


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