www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10580] New: spawnShell/pipeShell changes some environment variables (incl. PATH)

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10580

           Summary: spawnShell/pipeShell changes some environment
                    variables (incl. PATH)
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: critical
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: thelastmammoth gmail.com



----main.d:
import std.process;
import std.stdio;
void main(){
  writeln(environment["PATH"]);
  system("echo $PATH");
  spawnShell("echo $PATH").wait;
  spawnShell("echo $0").wait;  
}
----
(on OSX if that matters, and I've set my shell to zsh but this isn't the
problem)
export PATH=/usr/bin
path/to/dmd -run path/to/main.d
#this prints:
/usr/bin
/usr/bin
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:... (+ other stuff)
/go/bin
/bin/zsh

The bug is that spawnShell("echo $PATH") should IMO return the same as
system("echo $PATH").

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 08 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10580




it also changes these (at least on OSX):
MANPATH
SHLVL ( this one is normal though)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 08 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10580




furthermore the output of command env is returned in a different order

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 08 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10580


Lars T. Kyllingstad <bugzilla kyllingen.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla kyllingen.net



07:54:24 PDT ---
I cannot reproduce this on Linux, so it's hard to say what the issue is.  It
would be great if someone else could try this on OSX.

spawnShell() does not touch the environment unless explicitly requested, so I
think the answer lies somewhere else.

It looks almost like spawnShell() starts the shell as a login shell.  In that
case it would read various startup scripts, and re-set PATH along with some
other environment variables.  Could you please run the following commands in a
terminal?

  export PATH=/usr/bin
  $SHELL -c 'echo $PATH'
  $SHELL -l -c 'echo $PATH'

(Note the single quotes, which delay expansion of the PATH variable.)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 28 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10580


Lars T. Kyllingstad <bugzilla kyllingen.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|nobody puremagic.com        |bugzilla kyllingen.net


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 28 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10580


Lars T. Kyllingstad <bugzilla kyllingen.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|critical                    |major


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 06 2013