#!/usr/bin/env zsh typeset -A presets presets=( local "$HOME/.CVSROOT" banjo "adam@adamspiers.org:/home/adam/.CVSROOT" # lsm "lsm:/home/adams/.CVSROOT" # plig "adams@plig.net:/home/adams/.CVSROOT" # corelli "adam@corelli.new.ox.ac.uk:/home/adam/.CVSROOT" # share "/share/cvsroot" # proxy "proxy.guideguide.com:/share/cvsroot" ) usage () { cat < Change cwd's CVS/Root to newroot cvsroot -r Recursively change CVS/Root files to newroot Preset newroots are: EOF for k in "${(k@)presets}"; do printf "%10s: %s\n" $k "$presets[$k]" done exit 1 } if [ $# = 0 ]; then cat CVS/Root exit 0 fi if [ "$1" = '-r' ] && [ $# = 1 ]; then find . -path '*/CVS/Root' -print0 | xargs -0 cat exit fi if [ "$1" = '-d' ] && [ $# = 1 ]; then find . -path '*/CVS/Root' -print0 | perl -w0lne ' s!^\./!!; $width = length if length > ($width || 0); push @files, $_; END { foreach $file (@files) { open(F, $file) or die "open($file): $!\n"; (my $contents = ) =~ s/\n*$//; close(F); printf "%-${width}s %s\n", $file, $contents; } }' exit fi [ "$1" = '-h' ] && usage if [ "$1" = '-r' ]; then recursive=yes shift fi if (( ${+presets[$1]} )); then newroot="$presets[$1]" else newroot="$1" fi if [ -z "$recursive" ]; then perl -pi -e "s!^.*!q($newroot)!e" CVS/Root else find . -path '*/CVS/Root' -print0 | xargs -0 perl -pi -we "s!^.*!q($newroot)!e" fi