Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Avoid headaches from Strawberry Perl 5.10.0 and binary SVK

by Corion (Patriarch)
on Jan 09, 2008 at 14:18 UTC ( [id://661354]=note: print w/replies, xml ) Need Help??


in reply to Avoid headaches from Strawberry Perl 5.10.0 and binary SVK

There is no "command location caching", but what might trip you up is that changes to the environment made by .cmd or .bat files persist after the batch file has finished running. So once svk.bat moves the location of its own perl.exe in front of the location of your perl.exe in $ENV{PATH}, you will get the "wrong" perl.exe.

Similar things can happen in Unix as well if you're not careful with how you set up %ENV and where you modify it.

Replies are listed 'Best First'.
Re^2: Avoid headaches from Strawberry Perl 5.10.0 and binary SVK
by dragonchild (Archbishop) on Jan 09, 2008 at 16:17 UTC
    Similar things can happen in Unix as well if you're not careful with how you set up %ENV and where you modify it.

    I don't think so. If you run a script on Unix and it mucks with ENV, then when it terminates, that doesn't affect your ENV. There is no global ENV in Unix, unlike Windows.


    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

      This has nothing to do with the global environment variables. They are not being modified in any way here.

      Because .BAT files are interpreted by the shell (cmd.exe) itself, set commands modify it's own copy of the environment vars and as it persists after the .BAt file ends, so do the changes made to it. Within that command shell instance only.

      No other existing instances are affected. And no new instances will be affected, unless they are started as children of this instance, in which case they will inherit the modifications made to their parent. When this instance (and any children it started) ends, the modifications disappear.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        Changes made by a command in Unix cannot affect the shell the command was invoked from. This is because all commands are run in child processes. Apparently, Windows runs things in child threads?

        My criteria for good software:
        1. Does it work?
        2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
Re^2: Avoid headaches from Strawberry Perl 5.10.0 and binary SVK
by xdg (Monsignor) on Jan 09, 2008 at 15:38 UTC

    Supposedly the .bat file resets the PATH afterwards -- but maybe it doesn't in some cases (non-zero exit?). Here's the original:

    @echo off set APR_ICONV_PATH=C:\Program Files\svk\iconv set OLDPATH=%PATH% set PATH=C:\Program Files\svk\bin;%PATH% if "%OS%" == "Windows_NT" goto WinNT "C:\Program Files\svk\bin\perl" "C:\Program Files\svk\bin\svk" %1 %2 % +3 %4 %5 %6 %7 %8 %9 goto endofperl :WinNT "C:\Program Files\svk\bin\perl" "C:\Program Files\svk\bin\svk" %* if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl if %errorlevel% == 9009 echo You do not have SVK installed correctly. if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul set PATH=%OLDPATH% set APR_ICONV_PATH=

    -xdg

    Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

        No idea. I didn't write it. Maybe someone thought it would help in finding the DLL? (Superstition, I think.) Certainly, my hack of renaming and stripping all the PATH munging out seems to be working just fine.

        -xdg

        Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://661354]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2024-04-18 21:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found