From 54636435f1a40fd4cf00ecd0892a1784d2464d61 Mon Sep 17 00:00:00 2001 From: Laurence Withers Date: Mon, 24 Jul 2006 14:48:40 +0100 Subject: [PATCH] Add a module renaming script. --- skel/scripts/module-rename.sh | 45 +++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 skel/scripts/module-rename.sh diff --git a/skel/scripts/module-rename.sh b/skel/scripts/module-rename.sh new file mode 100755 index 0000000..36ca662 --- /dev/null +++ b/skel/scripts/module-rename.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# @P@/scripts/module-rename.sh +# +# (c)2006, Laurence Withers. Released under the GNU GPL. See file +# COPYING for more information / terms of license. +# + +# Renames a source module (e.g. "src/oldlib" -> "src/newlib") by running +# a sed script on all files to change filenames / headers. + + + +# Get the directory of the repository (needed to include functions file) +cd "$(dirname $0)" +REPOS=$(dirname "$(pwd)") +source "${REPOS}/scripts/functions.sh" || exit 1 + + + +# Get version etc. +if [ $# -ne 2 ] +then + echo "Usage: scripts/module-rename.sh " + exit 1 +fi +OLD="src/$1" +NEW="src/$2" + + +if [ ! -e ${OLD} ] +then + print_failure "${OLD} does not exist" + exit 1 +fi + +if [ -e ${NEW} ] +then + print_failure "${NEW} already exists" + exit 1 +fi + +echo "Moving ${OLD} -> ${NEW}" +do_cmd mv ${OLD} ${NEW} || exit 1 +do_cmd find ${NEW} -type f -exec sed -e "s,${OLD},${NEW},g" -i {} \; || exit 1 +print_success "Done"