Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#115 About changes to the process environment

4.0.0
closed
Mark Miesfeld
5
2012-08-14
2008-12-21
jfaucher
No

I did not find in the documentation a description of this interesting behavior : some commands like 'cd' or 'set' (and 'unset', 'export' on Unix) may have a direct side effect on the ooRexx process. The condition is that the command is simple, without redirection and without pipe.
Useful when you use ooRexx as a command window.
I propose a patch to update the Note about changes to the process environment, in section "How to Issue Commands" of Programming Guide.

Discussion

  • Mark Miesfeld
    Mark Miesfeld
    2008-12-21

    You're right that section in the doc is not really correct. Your patch is okay, but I think the note would still need some rewording. It doesn't make sense in the first paragraph of the note to say:

    When the host command returns, any changes to the process environment, such as changing the directory, are not passed back to the process running the Rexx program.

    and then say right after that:

    On Windows, the command CD is handled in the calling process ...

    Maybe you could just reword the whole note so that it was accurate and submit the patch again.

    --
    Mark Miesfeld

     
  • Mark Miesfeld
    Mark Miesfeld
    2008-12-21

    jfaucher,

    Below is a rough draft of rewording the whole note. Feel free to edit it as you would like. I would strongly encourage you to resubmit your patch with the whole note reworded. You would gain lots of points with me, and I'm sure all the developers, for submitting document patches.

    Note:

    Usually, when executing a host command addressed to the Windows or
    Unix/Linux command shell, that is, an expression that is passed to
    the system by address CMD as described above, a new process is
    created in the system command handler to execute the command.
    Changes in a child process environment do not effect, do not change,
    the parent process environment. Therefore, any change in the
    environment, such as a directory change, made by a host command
    executed in a child process would not be reflected in the process
    running the Rexx program.

    The interpreter attempts to mitigate this to some extent by
    executing some host commands in the process running the Rexx
    program, rather than in a child process. This is done so that
    changes to the environment made by executing the host command are
    visible in the process running the Rexx program.

    This is only done when the host command line is simple. That is,
    the command line must contain a single command, without redirection
    and without pipe. On Windows this applies to the CD and SET
    commands. On Unix-like systems, including Linux, this applies to
    cd, set, unset, and export. Rather than remembering the rules, it
    may be easier to avoid a potential problem by using the built in
    directory() or value() functions rather than issuing a host command
    for cd, set, etc.

    Some examples:

    'cd c:\tmp' / executed in Rexx program process /
    'cd /tmp' / executed in Rexx program process /
    'cd "c:\R&D (secret)"' / executed in Rexx program process /
    'cd c:\windows && dir c:' / executed in child process (2 commands) /
    'cd /tmp && pwd' / executed in child process (2 commands) /
    'd:' / executed in Rexx program process /
    'set myvar=my value' / executed in Rexx program process /

     
  • jfaucher
    jfaucher
    2008-12-22

    Mark,
    Thanks for having provided the updated note.
    Here is a new patch V2 which contains your text.
    I made two changes :
    - "do not effect, do not change" replaced by "do not change".
    - The examples are splitted in two parts : Windows, Unix.
    Some examples for Unix depend on another patch I submitted today.

     


Anonymous


Cancel   Add attachments