This is the mail archive of the guile@cygnus.com mailing list for the guile project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
*choke* I am utterly destroyed... [Greg sent the script below to me in personal E-mail, I suspect to avoid embarassing me. But that's not necessary. :) ] > For comparison (performance testing, perhaps?), this was my (very very) > quick hack to do the same thing a couple of week ago. It uses Zsh and > Perl (I'm sure it'd be faster if I just used one perl script, but, like > I said, I was interested in a mostly one-shot script). I'm a little > surprised that things were so long in the guile version--- perhaps some > of the wildcard matching functionality of Zsh would be nice to port to > guile. > > Greg > > #!/uns/bin/zsh -f > # cvs-change-repository <new-root-dir> > # By Greg J. Badros -- 12-June-1998 > # e.g. > # cvs-change-repository huis-clos.mit.edu:/usr/local/repository > FULLROOT=$1 > ROOT=${FULLROOT%/*} > REPO=${FULLROOT##*:} > echo "Changing root to be: $ROOT" > echo "Changing repository to be: $REPO" > perl -pi.bak -e 's%^.*$%'"$ROOT"'%' **/CVS/Root > perl -pi.bak -e 'my $extra = $ARGV; $extra =~ s%/?CVS/Repository$%%; if ($extra ne "") { $extra = "/$extra" } s%^.*$%'"$REPO"'$extra%' **/CVS/Repository Well, I don't care about the exact line count, but a good scripting language certainly shouldn't make you say more than you need to. Let's see what's going on here: - Mine does more error checking, but that really doesn't account for much of the size difference at all. - The ** wildcard lets you get a list of all the control files really easily. - Perl's -i construct is really winning for this particular case. - Perl's -p construct is quite winning, too. Now, if Guile had equivalents of these, but with nice names and good semantics, I'd be happy. The script still wouldn't be as short as yours, but it'd be more readable, and still in the range of plausibility. Is there anything else going on?