in reply to Windows Path
Welll (drawl) .. pretty nice, but .. how about a nice little DOSKEY macro assisted by Perl, to give you a nice UNI*-style path listing if you have HOMEDRIVE defined in your ENV, or DOS-style with proper right-leaning slashes if not? ($ENV{'HOMEDRIVE'} maps a drive to the UNI* root `/'; on my system that's `D:').
Could come in handy.
ms shell> DOSKEY RPATH=perl -e "@wp=split ';', $ENV{path};@wp=map {s# +\\#/#g; $_;} @wp; @PP=($uROOT=$ENV{'HOMEDRIVE'})? map {s#\A$uROOT##i; + s#\A([^^$uROOT]) (?:\:\/)#'/'. lc ${1} .((${1} eq $uROOT)? '':'/')#x +ei;$_;} @wp : @wp; @PP=map{s#\:##; $_;} @PP; print join qq'\n', @PP;"
This is equivalent to the one-liner below (DOSKEY macros cause us to generate rather obfuscated Perl, don't they :-)?
perl -e "@wp=split ';', $ENV{path};@wp=map {s#\\#/#g; $_;} @wp; @PP=($ +uROOT=$ENV{'HOMEDRIVE'})? map {s#\A$uROOT##i; s#\A([^$uROOT]) (?:\:\/ +)#'/'. lc $1 .(($1 eq $uROOT)? '':'/')#xei;$_;} @wp : @wp; @PP=map{s# +\:##; $_;} @PP; print join qq'\n', @PP;"
On my system, to illustrate what I mean, this is output:
/console /usr/local/bin/java/bin /MingW32/gcc-2.95.2/bin /bin /ActivePERL/bin /usr/bin /e/scr /c/WINNT/system32 /c/WINNT /c/stdJava/bin /usr/tmake/bin
Edited 2003.07.27 just clean-up.
Update 2003.08.03 -- A little observation regarding this old posting.
The code above would never have worked in MS Win9x, which has a 127-char limit on length of command lines. I have created a revised version of it which does work on Win9x, at the cost of some additional support complexity...
Update 2003.08.18 -- Refactored again since some temporary brain misfire cleared and I recalled the availability of the \l | \L operators to do what I was trying to accomplish with an eval.| DOSKEY macro in the form it takes as a macro file .mac on disk |
|---|
|
To support this, one needs to set a variable %D0%
in the environment:
SET D0=%HOMEDRIVE%
|
Obviously this is little more than a toy, there is very little utility to it. Still, I had some fun figuring out how to code it ;-).
The doubled-dollar signs ($$) in the code above are not dereferencing of anything in perl, they are there because as a macro on disk, the first $ will be eaten when the macro is read in by the Windows shell interpreter. They must be removed if the macro is input manually.
|
|---|