http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59484

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #1 from kargl at gcc dot gnu.org ---
(In reply to Reinhold Straub from comment #0)
> Please compile:
> 
> program test
>   implicit none
> 
>   character(len=11) :: cmdmsg,str
>   integer :: exitstat,cmdstat,status,length
>   logical :: wait
>   wait   = .true.
>   cmdmsg = "ok"
> 
>   call execute_command_line("export newvar='some text'")
>   print *,"result 1:", exitstat, cmdstat, cmdmsg
>   call get_environment_variable("newvar",str,length,status)
>   print *,"1:     ",str,length,status
>   print *,"expected:","some text",9,0; print *,""
> 

Looks like an invalid program to me.  exitstat, cmdstat, and cmdmsg
are undefined in the 1st print statement.

execute_command_line(command) executes the 'command' in a child
process.  You've managed to export newvar in the child's environment.
By the time you use get_environment_variable, the child process has
completed and more importantly it has not changed its parent 
environment.

If you want to change the parent's environment, you'll most likely
need to use ISO C interop and the setenv function from the C lib.

Reply via email to