- header.in
- add-header.sh
- add-header-dir.sh
- add-header-dir.sh ${codedir}
header.in(header info template)
/**************************************************************************** ** ** file: [filename] ** author: [your name] ** date: [date goes here] ** summary: ** Copyright (C) 2010 xxx GmbH and/or its subsidiary(-ies). ** All rights reserved. ** ****************************************************************************/
add-header.sh (add the header to single file)
if [ $# -ne 1 ]; then
echo "Usage: add-header.sh filename"
exit 1
fi
file=$1
# check if the header exists
firstline=`head -1 ${file}`
if [ "${firstline:0:2}" = "/*" ]; then
echo "header exists. do nothing."
else
# add header.in at the begin of the file
# and copy to a temp file
( cat header.in; cat ${file} ) > ${file}.new
# replace the [filename] by current file name
filename=`echo ${file}|sed "s,.*/\(.*\),\1,"`
sed -i "s#\[filename\]#$filename#g" ${file}.new
# replace the author name
author='Jingfeng Han'
sed -i "s#\[your name]#$author#g" ${file}.new
# replace the date
date=`date +"%y/%m/%d/"`
sed -i "s#\[date goes here]#$date#g" ${file}.new
# replace old file with the temp file
rm ${file}
mv ${file}.new ${file}
fi
exit 0
add-header-dir.sh (recursively add the header to all source in the fold)
find $1 -type f -iname "*.h" -o -iname "*.cpp" -o -iname "*.qml" | while read file; do
# display info
echo ${file} ...
# add header to the file
./add-header.sh ${file}
done
exit 0
No comments:
Post a Comment