Bug 1148318

Summary: Shell shows a lot of errors about importing functions
Product: [Fedora] Fedora Reporter: abyss.7
Component: bashAssignee: Ondrej Oprala <ooprala>
Status: CLOSED WONTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 21CC: admiller, fweimer, ooprala, ovasik
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-11-20 07:01:00 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:

Description abyss.7 2014-10-01 07:50:35 UTC
I have some functions in ~/.bashrc:

function find-grep {
  find . -name "$1" -type f -exec grep -FHn "$2" {} \;
}

export -f find-grep

But when I use different terminals and run different programs, I get these error messages - all at once:

sh: error importing function definition for `BASH_FUNC_find-grep'
/bin/bash: error importing function definition for `BASH_FUNC_find-grep'
/bin/sh: error importing function definition for `BASH_FUNC_find-grep'

Bash version: 4.3.25(1)-release (x86_64-redhat-linux-gnu)

Comment 1 Florian Weimer 2014-10-01 09:09:14 UTC
Do you need this function definitions only in interactive shells?  Then you can simply drop the “export -f” command.  The definitions will still be available because they are loaded from ~/.bashrc each time an interactive shell starts.

The culprit here is the “-” character in the function name.  The original upstream fix for CVE-2014-6271 added an additional requirement that imported function names follow the syntactic rules of shell variables, and “-” characters are not allowed in variable names, either.  This restriction was carried forward to the current patches in Fedora.

I think “export -f” should fail with an error here, to make it more obvious what's going on.

Comment 2 abyss.7 2014-11-20 07:01:00 UTC
Not fixed, but at least the problem is explained. Thanks.