From: g0dil Date: Tue, 15 Jan 2008 13:06:59 +0000 (+0000) Subject: Add '-f' option to force overwriting to '_templates/add.sh' X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=52afe5d05acf649159ddd5677415df45590c8979;p=senf.git Add '-f' option to force overwriting to '_templates/add.sh' git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@602 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/_templates/add.sh b/_templates/add.sh index 35d9df0..f56489b 100755 --- a/_templates/add.sh +++ b/_templates/add.sh @@ -2,7 +2,7 @@ if [ -z "$1" ]; then cat <. [] +Usage: $0 [-f] . [] Will add the file with that name to the current directory by copying the appropriate template and replacing the @NAME@ placeholders @@ -23,12 +23,20 @@ If is given, it is also set correctly replaced. If is unset but the environment variable SENF_AUTHOR is set, it's value is used. Otherwise, the @AUTHOR@ placeholder will need to be replaced manually. + +$0 will refrain from overwriting existing files except when the '-f' +option is specified. EOF exit 1 fi base="`dirname "$0"`"; base="`cd "$base"; pwd`" +if [ "$1" == "-f" ]; then + force=1 + shift +fi + type="${1##*.}" name="`basename "$1" ".$type"`" @@ -39,7 +47,7 @@ fi [ -z "$2" ] || SENF_AUTHOR="$2" -if [ -r "$1" ] ; then +if [ -z "$force" -a -r "$1" ] ; then echo "Target file '$1' exists." exit 1 fi