Bug 1148318 - Shell shows a lot of errors about importing functions
Summary: Shell shows a lot of errors about importing functions
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Fedora
Classification: Fedora
Component: bash
Version: 21
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Ondrej Oprala
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-10-01 07:50 UTC by abyss.7
Modified: 2016-02-01 02:10 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-11-20 07:01:00 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

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.


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