Looking at the output of env, I noticed there is also the following function.

BASH_FUNC_mc%%=() {  . /usr/share/mc/mc-wrapper.sh

The content of the /usr/share/mc/mc-wrapper.sh file is the following.

MC_USER=`id | sed 's/[^(]*(//;s/).*//'`
/usr/bin/mc -P "$MC_PWD_FILE" "$@"

if test -r "$MC_PWD_FILE"; then
        MC_PWD="`cat "$MC_PWD_FILE"`"
        if test -n "$MC_PWD" && test -d "$MC_PWD"; then
                cd "$MC_PWD"
        unset MC_PWD

rm -f "$MC_PWD_FILE"

What do the %% characters mean in the function name? Do they make it the function invoked in specific cases, or do they allow me to call it differently from other functions?

I am using openSUSE 42.3, with Bash version 4.3.42(1)-release (x86_64-suse-linux-gnu), if that makes any difference.


The function name was crafted by bash updated as a response to the shellshock vulnerability.

There was a function named mc that was exported and your bash version is renaming it by prepending BASH_FUNC_ and replacing () by %%.

$ d() { date ; }
$ export -f d
$ env | grep %%
BASH_FUNC_d%% { date

Here is the bash patch by Florian Weimer that introduced this fix, dated Sept 25 2014:


Note that a function name can contain almost any characters in bash just like a command name in general (i.e. a file name) so %% is definitely valid here.

| improve this answer | |

It seems that bash is quite happy to use % characters in function names:

bash$ TEST%%() { echo test; }
bash$ TEST%%

whereas e.g. dash doesn't like them:

$ TEST%%() { echo test; }
dash: 1: Syntax error: Bad function name

So as far as I can tell, %% doesn't have any special meaning in a bash function name. It would be just like using XX instead. This is despite the definition of a name in the manpage:

   name   A word consisting only of  alphanumeric  characters  and  under-
          scores,  and beginning with an alphabetic character or an under-
          score.  Also referred to as an identifier.
| improve this answer | |
  • But there is an equal = sign there after %%! Which causes assignment there. – αғsнιη Oct 29 '17 at 8:40
  • 2
    That is just how env printed the function definition. – Wodin Oct 29 '17 at 9:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.