Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
First off why does this only occur with %SystemRoo­t%

Other environment variables can be put in path components and CleanPath will handle them just fine. What it does special with %SystemRoot% is that if you put a directory in your $ENV{PATH} that is a subdirectory of %SystemRoot% without saying "%SystemRoot%", then CleanPath changes it to use %SystemRoot%. So "CleanPath C:\Windows\system32\trojans" will actually put "%SystemRoot%\trojans" into your path.

This feature was mostly added because the big motivation for writing this script was that a coworker had written a script to flush $ENV{PATH} changes into the registry and done a bad job of it, not realizing that $ENV{PATH} doesn't match what gets put in the registry for several reasons (notably user-specific path components and expansion of %SystemRoot%) so I wanted to clean this mess up easily (quite a few system had been corrupted by this before anyone noticed). If you use %SystemRoot%, then those entries in your $ENV{PATH} continue to work even if the drive letter for that partition changes on your when you reboot (and I was working in situations where this wasn't that uncommon of a situation); that's why those entries are done that way.

I wasn't too worried about the bug you pointed out because just running CleanPath twice takes care of it. I didn't include your fix at first because I needed to look over how I was using %GoodPath to convince myself that there were no problems with that fix. I just now incorporated your fix (slightly differently) as I was making some other minor updates. Thanks!

- tye        


In reply to Re^2: CleanPath (updated) by tye
in thread CleanPath by tye

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others romping around the Monastery: (6)
    As of 2015-07-28 02:48 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (251 votes), past polls