#! /bin/csh -f # Last edited on 2001-09-20 14:35:48 by stolfi # Usage: # # m3-rename-modules -f # # where is a sed(1) script that describes the # transformation from old module names to new module names. # # The command finds all Modula-3 source files (.i3, .m3, .ig, .mg, # m3makefile, and m3path) in the current directory, renames them # to new names as described by the given sed script, and then # pipes them through the given . set path = ( /usr/ucb /usr/bsd /usr/bin /bin ) if ( ( $#argv != 2 ) || ( "x$1" != "x-f" ) ) then echo "Usage: $0 -f " exit 1 endif set script = "$2" set temp = "/tmp/$$" rm -f ${temp}-OLD-FILES ${temp}-MAKEFILES find ./ -type f -name '[A-Za-z]*.[im][g3]' -print >> ${temp}-OLD-FILES find ./ -type f -name 'm3makefile' -print >> ${temp}-OLD-FILES find ./ -type f -name 'm3overrides' -print >> ${temp}-OLD-FILES find ./ -type f -name 'Makefile' -print >> ${temp}-OLD-FILES find ./ -type f -name 'makefile' -print >> ${temp}-OLD-FILES rm -f ${temp}-NEW-FILES # Rename files: foreach old ( `cat ${temp}-OLD-FILES` ) if ( ! ( -e $old ) ) then echo "file $old not found" else set new = "${old:h}/`echo ${old:t} | sed -f $script`" if ( "x$old" == "x$new" ) then echo "$old" >> ${temp}-NEW-FILES else if ( -e $new ) then echo "file $new already exists" echo "file $old unchanged" else echo -n "$old -> $new ?" if ( "x$<" == "xy" ) then set newdir = "${new:h}" if ( ! ( -e $newdir ) ) mkdir -p $newdir mv $old $new echo "$new" >> ${temp}-NEW-FILES else echo "$old" >> ${temp}-NEW-FILES endif endif endif end # Filter files through script: ${STOLFIHOME}/bin/sed-files -f $script `cat ${temp}-NEW-FILES | sort | uniq` rm ${temp}-OLD-FILES ${temp}-NEW-FILES exit 0