What does %% mean in a function name?

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:

http://seclists.org/oss-sec/2014/q3/att-693/variables-affix.patch

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.


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

bash$ TEST%%() { echo test; }
bash$ TEST%%
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.