Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have seen something like this in my bash ENV:

module=() {  eval `/usr/bin/modulecmd bash $*` }

How does this construct work? What is it called?

I'm not asking about modulecmd, I am asking about the entire construct.

share|improve this question
Are you sure you found it in that exact syntax (especially with the = sign)? Because for me, bash doesn't like it. However without the = it would be a function definition. – celtschk Aug 29 '14 at 16:13
Yeah, that is how it appears... There are several other examples of that also. Yeah, I tried it out and got an error from bash about it, but I have examples of it in my ENV. – mcede Aug 29 '14 at 16:30
up vote 10 down vote accepted

It's really a function named module. It appears in environment variables when you export a function.

$ test() { echo test; }
$ export -f test
$ env | sed -n '/test/{N;p}'
test=() {  echo test

From bash documentation - export:


 export [-fn] [-p] [name[=value]]

Mark each name to be passed to child processes in the environment. If the -f option is supplied, the names refer to shell functions; otherwise the names refer to shell variables. The -n option means to no longer mark each name for export. If no names are supplied, or if the -p option is given, a list of exported names is displayed. The -p option displays output in a form that may be reused as input. If a variable name is followed by =value, the value of the variable is set to value.

The return status is zero unless an invalid option is supplied, one of the names is not a valid shell variable name, or -f is supplied with a name that is not a shell function.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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