Opened 14 years ago

Closed 11 years ago

#395 closed defect (fixed)

IZ2173: Exported bash functions causes erroneous "environment" file

Reported by: paulu Owned by:
Priority: normal Milestone:
Component: sge Version: 6.0u8
Severity: minor Keywords: PC Linux execution


[Imported from gridengine issuezilla]

        Issue #:      2173             Platform:     PC       Reporter: paulu (paulu)
       Component:     gridengine          OS:        Linux
     Subcomponent:    execution        Version:      6.0u8       CC:
                                                                        [_] craffi
                                                                        [_] reuti
                                                                        [_] Remove selected CCs
        Status:       NEW              Priority:     P3
      Resolution:                     Issue type:    DEFECT
                                   Target milestone: ---
      Assigned to:    pollinger (pollinger)
      QA Contact:     pollinger
       * Summary:     Exported bash functions causes erroneous "environment" file
   Status whiteboard:

     Issue 2173 blocks:
   Votes for issue 2173:  16

   Opened: Wed Jan 24 14:11:00 -0700 2007 

Using the -V option of qrsh/qsub, the environment file created in the
spool directory is corrupt. Only one line of each exported bash function
is present in file "environment". This causes errors when a job is executed
via qrsh/qsub.

Steps to reproduce observed behaviour:

- login shell is /bin/bash
- shell_start_mode set to unix_behavior (may be irrelevant)
- define a function and export it:
  % blaah () { echo "blah blah"; }
  % declare -fx blaah
- submit job and see the errors:
  % qrsh uname -n
  bash: blaah: line 1: syntax error: unexpected end of file
  bash: error importing function definition for `blaah'
  bash: blaah: line 1: syntax error: unexpected end of file
  bash: error importing function definition for `blaah'

The command is executed alright. The errors are not fatal

   ------- Additional comments from reuti Thu Jan 25 08:51:33 -0700 2007 -------
added myself to cc

   ------- Additional comments from craffi Wed Jan 6 14:41:28 -0700 2010 -------
I'd like to tickle this bug to see if there is any way to get it resolved or perhaps we can increase it's priority?

I've got a client on SGE 6.2u4 using the popular 'modules' program to organize scientific applications and this issue is negatively
affecting users who see the awkward bash errors in their job output files.

Hopefully an easy fix, if you disable deletion of the temporary job directory and look directly at the 'environment' file in the job context
you see that SGE is basically truncating the trailing "}" character of a function definition statement.

   ------- Additional comments from reuti Wed Jan 6 14:58:10 -0700 2010 -------
The question is: how is SGE reading the environment file? Line by line and export each of the found entries? Then this behavior needs to be
changed and lines concatenated for the function. At least inside bash you need also `export -f <name>` to export a function. It seems not to
be possible in one step like it can be done with other environment variables.

   ------- Additional comments from fx Thu Jan 14 06:21:52 -0700 2010 -------
This seems to have been partly addressed by the currently-latest
change to sge_var.c, but that looks wrong to me.
`var_list_dump_to_file' converts newlines to "\n", but it should also
double backslashes beforehand, and doesn't.  However, `getenv_and_set'
just discards newlines rather than undoing the conversion to \n.

Change History (1)

comment:1 Changed 11 years ago by dlove

  • Resolution set to fixed
  • Severity set to minor
  • Status changed from new to closed

Fixed by [3556].

Note: See TracTickets for help on using tickets.