[GE users] Error with "export -f" shell (bash) functions

rayson rayrayson at gmail.com
Wed Jan 13 20:36:24 GMT 2010


Note that the SGE clients happily record all the function variables,
but bash internally puts a newline before the closing }.

First problem: before setting up the environment there already is missing a "}".

$ env
...
blaah=() {  echo "blah blah"
}
...

The environment file (from qsub -V sleep):
...
blaah=() {  echo "blah blah"
...

Note that the value returned from getenv("blaah") does have the }.


Second problem, while it seems like one needs to use a special way to
set up the function variables, it is possible to do it without any
special system calls. I have correctly setup an environment function
variable in a simple C program, which then executes /bin/bash . So may
be a minor fix here or there can get rid of this problem...

bash does not like the function body to be all in one line, at least
the closing } needs to be in a new line -- if I put everything all in
one line, bash complains, and if I put the closing } in a new line,
bash is happy:

main()
{
 putenv("func2=() {  echo function } ");

 system("/bin/bash");
}

$ ./a.out
bash: func2: line 1: syntax error: unexpected end of file
bash: error importing function definition for `func2'


* Note: new line ( \n ) added in the following:
main()
{
 putenv("func2=() {  echo function \n } ");

 system("/bin/bash");
}

$ ./a.out
$ func2
function


So, I think it is not too hard to fix this problem -- we only need to
make sure that the closing } is recorded during job submission, and it
is set correctly during the environment variable setup stage in
shepherd.

Rayson




On Wed, Jan 13, 2010 at 1:06 PM, craffi <dag at sonsorol.org> wrote:
> This is a known and documented bug with SGE and only happens with the
> use of bash when you define functions within ENV variables.
>
> The bug report is here:
>
> SGE Issue 2173 http://bit.ly/8VzAQc
>
> .. consider making an account on the site and casting your "vote" for
> this issue to be fixed.
>
> There are some workarounds and I do know people who use "modules" and
> bash but I can't recall offhand what the mitigation method was. I'll
> search through my notes.
>
> -Chris
>
>
>
>
> madskaddie wrote:
>> Greetings,
>>
>> I installed the GridEngine 6.2u4 (open source ver.) and whenever the environment has a shell function exported via "export -f func_name", it outputs:
>>
>> "
>> /bin/bash: func_name: line 1: syntax error: unexpected end of file
>> /bin/bash: error importing function definition for `func_name'
>> "
>> Example:
>>
>> qrsh -V date
>>
>> bash: module: line 1: syntax error: unexpected end of file
>> bash: error importing function definition for `module'
>> bash: test_fun: line 1: syntax error: unexpected end of file
>> bash: error importing function definition for `test_fun
>>
>>
>> Can anybody help me fixing this ?
>>
>> Thanks
>>
>> ------------------------------------------------------
>> http://gridengine.sunsource.net/ds/viewMessage.do?dsForumId=38&dsMessageId=238562
>>
>> To unsubscribe from this discussion, e-mail: [users-unsubscribe at gridengine.sunsource.net].
>
> ------------------------------------------------------
> http://gridengine.sunsource.net/ds/viewMessage.do?dsForumId=38&dsMessageId=238580
>
> To unsubscribe from this discussion, e-mail: [users-unsubscribe at gridengine.sunsource.net].
>

------------------------------------------------------
http://gridengine.sunsource.net/ds/viewMessage.do?dsForumId=38&dsMessageId=238597

To unsubscribe from this discussion, e-mail: [users-unsubscribe at gridengine.sunsource.net].



More information about the gridengine-users mailing list