#! /bin/csh -f -e # Usage: # # rename-m3-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 . if ( ( $#argv != 2 ) || ( "x$1" != "x-f" ) ) then echo "Usage: rename-m3-modules -f " exit 1 endif set script = "$2" /usr/bin/find ./ -type f -name '[A-Z]*.[im][g3]' -print > ,@OLD-SOURCES /usr/bin/find ./ -type f -name 'm3makefile' -print > ,@MAKEFILES /usr/bin/find ./ -type f -name 'm3path' -print >> ,@MAKEFILES /usr/bin/find ./ -type f -name 'Makefile' -print >> ,@MAKEFILES /bin/rm -f ,@NEW-SOURCES # Rename files: foreach old ( `cat ,@OLD-SOURCES` ) if ( ! ( -e $old ) ) then echo "file $old not found" else set new = "`echo $old | sed -f $script`" if ( "x$old" == "x$new" ) then echo "$old" >> ,@NEW-SOURCES else if ( -e $new ) then echo "file $new already exists" else echo -n "$old -> $new ?" if ( "x$<" == "xy" ) then mv $old $new echo "$new" >> ,@NEW-SOURCES else echo "$old" >> ,@NEW-SOURCES endif endif endif end # Filter files through script: /udir/stolfi/bin/sed-files -f $script `cat ,@NEW-SOURCES ,@MAKEFILES | sort` /bin/rm ,@OLD-SOURCES ,@NEW-SOURCES ,@MAKEFILES exit 0