Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Private Utilities

by Intrepid (Deacon)
on Dec 01, 2005 at 08:29 UTC ( #513214=note: print w/replies, xml ) Need Help??


in reply to Private Utilities

<UPDATE> prompted by a reaction in the chatterbox

If you get upset by things like seeing the company name "Microsoft" rendered in various creative / implicitly critical ways, please stop reading now; I don't want to inadvertantly help you even to a tiny degree with this code! Making even one of your days a tiny bit easier might distract you from the important recognition that you've got far worse problems than doskey macros to deal with (problems of an cognitive sort), and it would thus be uncompassionate of me. Shoo.

</UPDATE>

I was just looking at how impoverished* my Windo$e CMD.exe prompt seemed (I go months without using one, but building Perl under Win32(native) a little while ago made me get re-acquainted with it). I decided to pull together a few doskey macros that could be loaded into a CMD session at any point (by running a batch *.cmd file). Here they are.

* compared with my Cygwin shell

@ECHO OFF rem ark * We have to get perl into our path so this tries to make sur +e rem * that it will be. Tested *only* on Windows XP. Most users mi +ght rem * just as well remove this if they are sure Perl is always in + PATH. @PATH | findstr /R /I /O "perl[^\\]*\\bin" >NUL @if ERRORLEVEL 1 ( REM EMBER TO adjust this for the path to perl.EXE on your system. set PATH=c:\ADDITI~1\win32perl\bin;%PATH% ) rem desc * a better dir command that outputs what we expect such a com +mand rem * to do, w/o the leading and trailing junk. doskey udir=perl -le "$ad=pop(@ARGV);$ad=q[.] unless $ad;@zult=(grep{$ +_ and not /\A\s/}grep[chomp],`cmd /c dir $ad /N/Q/TW`);for((grep subs +tr($_,24,5) eq q[<DIR>],@zult),(grep substr($_,24,5) ne q[<DIR>],@zul +t)){s{\s\s[[:upper:]]+\\}{};print}" $* doskey uloc=perl -MFile::Find=find -MEnv=@PATH -wle "$ARGV[0]=qw[ $* ] +;die q[An argument is required! Aborting.] unless $ARGV[0];print qq/L +ooking for $ARGV[0]/;@lf=$ARGV[0];push @lf,qq|$ARGV[0].exe| unless $A +RGV[0]=~/\.exe$/i; find(sub{$ef=$_;return unless grep{$ef eq $_ or /\ +A\Q$ef\E\z/i}@lf;$ff=$File::Find::name;$ff=~y:/:\\:;print $ff and exi +t 0},@PATH); print q[None found.]" doskey pmquery=perl -le "do{$modn=$_;s!::!/!g;$_.=q[.pm];print qq[$mod +n is not installed.\n] and next if !(eval{require \"$_\";1} and !$@); +$modv=defined(${$modn.q[::VERSION]}) ?${$modn.q[::VERSION]}:q{[versio +n undefined]};$numtyp=(2>$modv=~tr/.//) ?'%%s':'%% 6d';printf qq[ %% +-*s $numtyp in %%s\n],(length>30 ? 5+length:15+length),$modn,$modv,$I +NC{$_}}for @ARGV;" $* doskey perlv=perl -le "printf qq[%%vd$/]=> $^V" doskey checkpath=perl -MEnv=@PATH -le "print for map {-d $_ ? lcfirst( +$_):qq[$_ ** DOES NOT EXIST **]}@PATH" doskey checkperlinc=perl -le "print for map {-d $_ ? lcfirst($_):qq[$_ + ** DOES NOT EXIST **]}@INC" doskey checktempdirs=perl -e "print for map {sprintf(q[%%-6s is %%s].q +q[\n], $_, ($ENV{$_} || 'not defined in env'))}qw(TEMP TMP TMPDIR)"

  • pmquery tells us the location and (if applicable) version of an installed Perl module. Quite useful.
  • perlv simply prints the familiar (new 'v-string' style) Perl version.
  • checkpath pretty-prints the elements in PATH, one per line.
  • checkperlinc pretty-prints the elements in Perl's @INC, one per line.
  • checktempdirs shows what each of the commonly looked-at temporary file locations is defined to, or shows if it is not.
  • uloc and udir are my experiments with reimplementing the `which' and `dir' commands. uloc in particular is not truly reliable.

Note that as Windo$e CMD shell has no concept of "continuing a single command over multiple lines by escaping the line-endings (with "\"), these doskey definitions must be single lines, no matter how they end up looking on your screen (in a browser or editor). Cleaning them up is the reader's responsibility.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://513214]
help
Chatterbox?
[stevieb]: it is exceptionally difficult I'm finding to debug a dist that is x-platform, where on each platform you're wrapping a different binary. Trying to co-ordinate a successful test run where tests are extensive is a nightmare, especially when the dist...
[stevieb]: ...you're testing is a test system itself. 10+ documented issues fixed, another half dozen found while fixing the original ones. I'm getting there...
[stevieb]: Then throw in changes to Windows that throws everything you trusted right out the window.
[shmem]: that's why it is called "Windows"
[stevieb]: shmem thanks for the 'insight' :P
[shmem]: good thing that Sun already took "OpenWindows", otherwise I'd not stop to shudder imagining an "OpenWindows" from MS
[shmem]: more garbage in, more garbage out that would be
[stevieb]: I found that win10 broke a C# library I was using for one project while enhancing tests for a Perl dist, which breaks other Perl dists, and I'm about to throw my hands up on berrybrew. win2k12 broke one thing, win10 breaks something...
[stevieb]: ...unrelated which requires replacing a lot of code and a whole lib. I'm about to go nix only ffs
[shmem]: stevieb: what you're doing sounds afwully complex. Too much for me this evening to provide brighter insight ;-)

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2017-03-28 22:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (342 votes). Check out past polls.