Brian's Waste of Time

Tue, 13 Jan 2004

cvs udpate -dP

I have done a brief survey of the developers I work with and discovered that what I had attributed to (mild) undiagnosed dyslexia in myself is really a very common typo. Apparently lots of people use cvs udpate quite frequently. So, in honor of the cvs udpaters out there:


#!/usr/bin/env ruby
#
# =Usage
# Replace value of REAL_CVS with the full path to the real cvs executable
# and then rename this file to 'cvs' and place it in a directory in your
# PATH which will be searched before the one containing the real cvs binary
#
# You can modify the speling hash to correct things for you =)
#
REAL_CVS='/usr/bin/cvs'

speling = 
{
    'udpate' => 'update'
}

line = "#{REAL_CVS} #{ARGV.join(' ')}"
speling.each { |key, value| line.gsub!(Regexp.compile(key), value)}
Kernel.exec(line)

A better implementation would parse out cvs options correctly to make sure that it didn't "fix" any filenames in the command line.

5 writebacks [/src] permanent link