#! /bin/sh

prog="`basename $0`"
fvwmrc="$1"
[ x$fvwmrc != x ] || { echo >&2 "usage: \"$prog FILENAME\""; exit 1; }

# This is going to be a hideous regexp.  I want to replace
#  80-character lines with 60-character lines, preserving three
#  substrings, _and_ I'm doing it as a "-e" argument to perl!
# Ick.
echo "Modifying \"$fvwmrc\"." >&2
echo "(The old file is backed up as \"$fvwmrc.bak\")" >&2
perl -w -pi.bak -e '(s,([Ee]xec\s+\S*\s*)/bin/csh\s+-cf\s+\"\s*set\s+add_opts\s+=\s+\(?([^\s\(\)]+)\)?\s*;\s*source\s+/usr/athena/lib/init/add\s*;\s*(\S+)\s*\",$1/mit/windowmanagers/arch/share/bin/addandrun $2 $3,) && print STDERR ".\n";' "$fvwmrc"
echo "done" >&2
