#1572 TEMP env var is corrupted when running external app

MSYS
pending
Cesar Strauss
None
Bug
rejected
Unknown
False
2013-02-08
2011-08-14
Orgad Shaneh
No

On my machine, TEMP environment variable is defined as 'D:\Temp'.

When I run msys, 'echo $TEMP' gives '/tmp', and 'msysmnt' shows that D:\Temp is mounted on /tmp. That's fine.

When I run an external application from msys, the TEMP variable is modified to 'D:/Temp'.

To reproduce: Run msys, from it, run cmd /c "echo %TEMP%"

Discussion

1 2 3 .. 5 > >> (Page 1 of 5)
  • Earnie Boyd
    Earnie Boyd
    2011-08-15

    • milestone: --> 456516
    • status: open --> pending
     
  • Earnie Boyd
    Earnie Boyd
    2011-08-15

    You fail to say how this affects your use of native programs? I.E.: Why are you concerned about D:/Temp instead of D:\Temp?

     
  • Orgad Shaneh
    Orgad Shaneh
    2011-08-15

    Consider the following perl script:

    $TDIR=$ENV{TEMP};
    $fname = "$TDIR\\hello.txt";
    open (test, ">$fname");
    print test "Hello\n";
    close (test);

    Running on cmd, NOT running under msys...

     
  • Orgad Shaneh
    Orgad Shaneh
    2011-08-15

    • status: pending --> open
     
  • Keith Marshall
    Keith Marshall
    2011-08-15

    What perl are you trying to run, in your example? If it is the MSYS perl, then you should be running it from the MSYS shell, *not* from cmd.exe. Attempting to run *any* MSYS program from cmd.exe is an ID-ten-T user error; such usage is unsupported.

    FWIW, your example WJFFM, when correctly run using MSYS perl, invoked from the MSYS shell prompt.

     
  • Keith Marshall
    Keith Marshall
    2011-08-15

    • status: open --> pending
     
  • Earnie Boyd
    Earnie Boyd
    2011-08-15

    • status: pending --> closed-works-for-me
     
  • Earnie Boyd
    Earnie Boyd
    2011-08-15

    Even so, I have no issue with the sample given with either running in a cmd.exe environment or a MSYS bash environment. I tested both the MSYS dependent perl and the ActiveState version of perl. Therefore I've closed the ticket but feel free to comment if you have more information.

     
  • Orgad Shaneh
    Orgad Shaneh
    2011-08-16

    Do you seriously suggest that msys SHOULD manipulate environment variables? I can't see your point.

    Even if my small example (I'm using ActivePerl v5.12.3) does work, is this an expected behavior?

    Here is a command that won't work as expected when run from msys:
    @if %TEMP%==D:\TEMP (echo Hello) else (echo Goodbye)

    If %TEMP% is set to D:\TEMP, on cmd it prints Hello, on cmd run from msys it prints Goodbye.

    Another example (from command line):
    copy file.ext %TEMP%

    Works on cmd, doesn't work when cmd is run from msys...

     
  • Earnie Boyd
    Earnie Boyd
    2011-08-16

    Yes, it is expected behavior.

    Your use of %TEMP% in the MSYS shell isn't correct. The MSYS shell will not evaluate %TEMP% to be the value of a variable but as a literal string. You would need to use $TEMP and as Keith has already stated, that while some things may work it isn't expected that you will be using MSYS from cmd.exe but instead using the MSYS shell. It is also expected that while in the MSYS shell you use POSIX semantics instead of Windows semantics.

     
1 2 3 .. 5 > >> (Page 1 of 5)