Monday, October 12, 2009

whereis for Windows

One of the utilities that had written at UPS was 'whereis'. Windows does not have such a thing (or if it does, it is called something else). It is a useful program and I resolved a number of problems with it.

The 'whereis' program tells you where a specific command is located. In our Windows systems, we had multiple copies of programs named 'find', 'diff', and 'sort'. The different versions behaved differently, and we found it important to set the PATH variable properly for our applications. The 'whereis' program helped us identify errors in the PATH variable.

Today I missed my old friend, so I decided to write it. (Write it again, since I do not have access to the programs I wrote at UPS.)

My old version was in Perl. My new version is in Ruby. The new version is much cleaner than the old version. I remember that I had a number of issues with the original program, and I needed several weeks (working on and off) to get the program correct.

The Ruby version is shorter, cleaner, and correct. It comes it at 20 lines (including comments and blank lines). I think that is about half the length of the Perl version. I built the program in three stages, testing each stage as I went. Total time: about ten minutes. (Less time that it took me to write this entry!)


No comments:

Post a Comment