Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

So I found a way to transfer environment variables through ssh without having to change neither server nor client: Transferring environment variable through SSH / quoting in bash/sh/csh/tcsh

But I would also like to be able to transfer bash functions like this one:

$ myfunc() {
> echo Func $1
> }
$ export -f myfunc
$ parallel myfunc ::: a
Func a

Functions are not transferred through ssh:

$ parallel -S server myfunc ::: a
bash: myfunc: command not found
$ parallel --env myfunc -S server myfunc ::: a
bash: line 2: myfunc: command not found

But the content of the function is transferred nicely:

$ parallel --env myfunc -S server echo \$myfunc ::: a
() { echo Func $1} a

So it seems all I need to do now is to somehow tell bash that $myfunc is really the function myfunc.

How can I do that?

share|improve this question
up vote 1 down vote accepted

That actually proved to be fairly easy (except it does not work in csh). Simply do:

eval myfunc$myfunc

It unfortunately crashes normal variables, to avoid this only do the eval for variables for which the content start with '() {'; that seems to be bash's signature for functions.

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.