This post originated from an RSS feed registered with Perl Buzz
by Chris Winters.
Original Post: Various shell miseries
Feed Title: cwinters.com
Feed URL: http://www.cwinters.com/raw/cwinters_perl.rdf
Feed Description: Chris Winters on Perl, programming and technology
Misery #1: Beware single quotes in the Win32 shell!
The modern Win32 shell (cmd.exe, how I loathe thee) treats single- and double-quotes differently than the typical Unix shell. How did this bite me? I wrote a quickie Perl script to let a co-worker find all places where one or more of a gaggle of fields were used in a set of stored procedures. Not too tough, and I can continue spread the Perl virus. We write it on my machine, test it out and it works great. I commit it to CVS and we go over to his machine to grab it from CVS and run it.
Except it doesn't work. I'm using the same effing arguments as on my machine but it's not working. I cycle through a number of debugging techniques (which is instructive to my non-Perlish co-worker) but none of them work -- the directory scanner is finding the right files, the file actually has the string to match, it's not case-sensitive. Then I print out what the program is trying to match. And it's got an extra set of single quotes around it, like this: ''MATCH TEXT''. Dammit! I was using the single quotes to delimit the argument, not to be included in the argument. Bastards!
Change the singles to doubles and everything is peachy. Thanks Microsoft! Future warning: always test in your future environment, as I tested on my machine initially with cygwin, which while a band-aid over gaping MS wounds is still decent.
Misery #2: Beware of binary path caching!
In the process of stocking my new Powerbook (status: honeymoon continues) I installed the newest version of Maven, RC1. Everything built on the Powerbook just fine so I decided to see if it would work in our normal environment. Download the ZIP, unpack it and stock the repository like it says, modify my MAVEN_HOME and PATH environment variables and run it. I get:
$ maven clean.all
java.lang.NoClassDefFoundError: com/werken/forehead/Forehead
Exception in thread "main"
WTF? Okay, maybe the repository didn't get created properly? Nope, it's okay. I specified the right paths in the environment, right? Yep. Okay, maybe it'll work in the dreaded cmd.exe (how I loathe thee) shell? Nope, same result. Google around, no joy, just messages about MAVEN_HOME not being set, but mine is.
Sneaky suspicion:
$ which maven
/cygdrive/c/java/maven-1.0-beta-10/bin/maven
Foiled again! Calling maven with the fully-qualified path works fine. Bad shell for caching the path to the script!