Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: Cleaning %PATH% with WinBatch

by swl (Vicar)
on May 22, 2022 at 22:24 UTC ( #11144102=note: print w/replies, xml ) Need Help??

in reply to Cleaning %PATH% with WinBatch

I don't think this addresses your issue but seems generally relevant and maybe useful to know.

Substrings can be removed using the idiom below.

set PATH=%PATH:C:\perls\strawberry-perl-\perl\b +in;=%

A looped example and some gotchas are in this SO post.

Replies are listed 'Best First'.
Re^2: Cleaning %PATH% with WinBatch
by LanX (Sage) on May 22, 2022 at 22:48 UTC
    Thanks, I knew that construct and that SO thread already.

    Actually that's exactly how I inserted the "DISABLED" part, see demo here.

    Problem is that, like already explained, I would need to know all possible entries beforehand instead of being able to exclude anything following C:\perls\...

    I also looked into batch solutions to split on ; and loop over it. But that's not trivial because, believe it or not, a ";" could be part of a filename° and appending to a variable in a loop is not trivial in WinB*tch language... 🤦

    In short: batch is really a horrible language for a perverted file-system invented by a distorted sadist. ˛

    I'm thinking now it's a good bargain between mental sanity, maintainability and performance to use a Perl one-liner returning the cleaned path. But only called for that edge case, i.e. if batch detects C:\perls in the path.

    (I could also use PowerShell, but why adding one more technology at that place?)

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

    °) tho, I could ignore this problem as long as the paths of my Perl installations are clean, which goes without saying.

    ˛) I have to apologize that was too harsh.

    It's rather a mix of the worst parts of bash and zsh, with the source google translated to Chinese and back to English but via Khoisan, while purging all documentation during compilation with random settings.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2023-02-05 14:43 GMT
Find Nodes?
    Voting Booth?
    I prefer not to run the latest version of Perl because:

    Results (31 votes). Check out past polls.