summaryrefslogtreecommitdiffstats
path: root/libtoprammer/bit/src/create.sh
blob: 22f18af4863d29260b648a84af06288bc75fce1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
# Create source template
# Copyright (c) 2010 Michael Buesch <mb@bu3sch.de>
# Licensed under the GNU/GPL v2+

basedir="$(dirname "$0")"
[ "${basedir:0:1}" = "/" ] || basedir="$PWD/$basedir"

template="$basedir/template"

set -e

function usage
{
	echo "Usage: create.sh TARGET_NAME"
}

if [ $# -ne 1 ]; then
	usage
	exit 1
fi
name="$1"

target="$basedir/$name"

mkdir -p "$target"
for file in $(ls $template); do
	suffix="$(echo $file | cut -d. -f2)"
	targetfile="$name.$suffix"
	[ $file != Makefile ] || targetfile=$file
	cat $template/$file | sed -e 's/template/'$name'/' >$target/$targetfile
done

exit 0
bues.ch cgit interface