'Unexpected end of file' and 'error importing function definition' error running shellscript using qsub

Also have this problem in a wrapper script that uses

qsub -shell no -b yes -cwd -V somescript.bash arg1 arg2 etc

if you use it to submit another bash shell script. It produces the annonying

/bin/sh: module: line 1: syntax error: unexpected end of file
/bin/sh: error importing function definition for `BASH_FUNC_module'

(this is Sun Grid Engine 211.11 running on CentOS 6.6) Turns out things are solved by simply putting the following on top of the wrapper script (not of the wrapped script):

unset module

That's all.


In /usr/share/Modules/init/bash commented out the 'export -f module' line.

In a normal login shell, modules.sh will be called from profile.d so the module command is available. In a non login shell, like an app wrapper script it just source the above file first.

Generally in applications script after sourcing above file they again give command "module load apps/vendor/app" which means extra sourcing.

Reference::- http://gridengine.org/pipermail/users/2011-November/002019.html


For some reason unknown to me adding semicolons at the end of every line fixed the problem.