Bug 1237213

Summary: Importing Exported Functions with Hyphens
Product: Red Hat Enterprise Linux 7 Reporter: Martin Kyral <mkyral>
Component: bashAssignee: Ondrej Oprala <ooprala>
Status: CLOSED ERRATA QA Contact: Martin Kyral <mkyral>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.1CC: cperl, dkutalek, fweimer, jkejda, johnlcf, ooprala, ovasik
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: bash-4.2.46-18.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1148507 Environment:
Last Closed: 2015-11-19 04:39:53 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:
Bug Depends On: 1148507    
Bug Blocks:    

Description Martin Kyral 2015-06-30 14:36:40 UTC
+++ This bug was initially created as a clone of Bug #1148507 +++

Description of problem:

Importing of functions that were previously exported with `export -f' fails if the function name contains a hyphen (i.e. '-').

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

bash-4.1.2-15.el6_5.2

How reproducible:

Always:

[cperl@localhost /tmp]$ rpm -qa bash
bash-4.1.2-15.el6_5.2.x86_64
[cperl@localhost /tmp]$ foo-bar () { echo a; }
[cperl@localhost /tmp]$ foo-bar
a
[cperl@localhost /tmp]$ export -f foo-bar
[cperl@localhost /tmp]$ bash
bash: error importing function definition for `BASH_FUNC_foo-bar'
[cperl@localhost /tmp]$ 

Actual results:

Importing of previously exported functions whose name have a hyphen in them fails.

Expected results:

Importing of previously exported functions whose name have a hyphen in them should work.

Additional info:

This has been discussed in a few places already [1][2].  However, it looks like the latest upstream patch at [3] (bash 4.3, patch 27, git commit 3590145af6f1c9fa321dff231f69ae696e7e740b) actually fixes this.

I believe the relevant part of the patch is:

-         if (legal_identifier (name))
-           parse_and_execute (temp_string, name, SEVAL_NONINT|SEVAL_NOHIST|SEVAL_FUNCDEF|SEVAL_ONECMD);
+         if (absolute_program (tname) == 0 && (posixly_correct == 0 || legal_identifier (tname)))
+           parse_and_execute (temp_string, tname, SEVAL_NONINT|SEVAL_NOHIST|SEVAL_FUNCDEF|SEVAL_ONECMD);

Would it be possible to release a new bash 4.1 package for RHEL 6.5 with the patch updated to accommodate this change?

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1148318 (this is for fedora, which is why I'm opening this bug)
[2] https://lists.gnu.org/archive/html/bug-bash/2014-09/msg00186.html
[3] git://git.savannah.gnu.org/bash.git


---------------------------------------------------------------------------

The same bug is present in RHEL 7.1. It shall be fixed here as upgrading from RHEL 6 (fixed) to RHEL 7 (unfixed) would cause regression.

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

bash-4.2.46-12.el7

Comment 5 errata-xmlrpc 2015-11-19 04:39:53 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-2144.html