给代码添加版权信息
版权声明:本文系作者原创。未经许可,不得转载。
以前写的代码没有加上版权信息。后来要全部添加,一个一个添加当然很慢,于是写了一个脚本自动添加。
基本思路:
1、列出目录下所有文件
2、得到后缀名,根据后缀名添加不同格式的信息。
脚本如下:
AddCopyrightInformation/addInfoToAllFile.sh
#!/bin/bash
[ "$1" ] || {
echo "Usage: $0 /dir/path"
exit 1
}
_dir=$1
filelist=`./script/getAllFile.sh $_dir`
for file in $filelist
do
infotype=`./script/judgeInfoType.sh $file`
./script/addToSingleFile.sh $file $infotype
done
AddCopyrightInformation/script/addToSingleFile.sh
#!/bin/sh
filepath=$1
infotype=$2
if [ "$infotype"x = "asterisk"x ]; then
cat ./info/cppinfo.txt $filepath > $filepath.tmp
mv $filepath.tmp $filepath
elif [ "$infotype"x = "octothorpe"x ]; then
cat ./info/shellinfo.txt $filepath > $filepath.tmp
mv $filepath.tmp $filepath
elif [ "$infotype"x = "hyphen"x ]; then
cat ./info/xmlinfo.txt $filepath > $filepath.tmp
mv $filepath.tmp $filepath
fi
AddCopyrightInformation/script/getAllFile.sh
#!/bin/bash
nowdir=$1
find $nowdir -type f
AddCopyrightInformation/script/judgeInfoType.sh
#!/bin/bash
[ "$1" ] || {
echo "Usage: $0 filepath"
exit 1
}
filepath=$1
filename=`basename $filepath`
extensionname=${filename##*.}
if [ "$extensionname"x = "cpp"x ]; then
echo "asterisk"
elif [ "$extensionname"x = "qml"x ]; then
echo "asterisk"
elif [ "$extensionname"x = "spec"x ]; then
echo "octothorpe"
elif [ "$extensionname"x = "h"x ]; then
echo "asterisk"
elif [ "$extensionname"x = "pro"x ]; then
echo "octothorpe"
elif [ "$extensionname"x = "pri"x ]; then
echo "octothorpe"
elif [ "$extensionname"x = "js"x ]; then
echo "asterisk"
fi
AddCopyrightInformation/info/cppinfo.txt
/*
This file is part of cmos-compositor
*Copyright (C) 2014 Beijing Yuan Xin Technology Co.,Ltd. All rights reserved.
*Authors:
Peng Huaping <penghuaping@syberos.com>
Xie Yan <xieyan@syberos.com>
Li Jing <lijing@syberos.com>
Liu Jiawei <liujiawei@syberos.com>
This software, including documentation, is protected by copyright controlled
-
by Beijing Yuan Xin Technology Co.,Ltd. All rights are reserved.
*/AddCopyrightInformation/info/shellinfo.txt
#
# This file is part of cmos-compositor
#
# Copyright (C) 2014 Beijing Yuan Xin Technology Co.,Ltd. All rights reserved.
#
# Authors:
# Peng Huaping <penghuaping@syberos.com>
# Xie Yan <xieyan@syberos.com>
# Li Jing <lijing@syberos.com>
# Liu Jiawei <liujiawei@syberos.com>
#
# This software, including documentation, is protected by copyright controlled
# by Beijing Yuan Xin Technology Co.,Ltd. All rights are reserved.
#AddCopyrightInformation/info/xmlinfo.txt
<!-- -->
<!-- This file is part of cmos-compositor -->
<!-- -->
<!-- Copyright (C) 2014 Beijing Yuan Xin Technology Co.,Ltd. All rights reserved. -->
<!-- -->
<!-- Authors: -->
<!-- Peng Huaping <penghuaping@syberos.com> -->
<!-- Xie Yan <xieyan@syberos.com> -->
<!-- Li Jing <lijing@syberos.com> -->
<!-- Liu Jiawei <liujiawei@syberos.com> -->
<!-- -->
<!-- This software, including documentation, is protected by copyright controlled -->
<!-- by Beijing Yuan Xin Technology Co.,Ltd. All rights are reserved. -->
<!-- -->使用方式如下:
1、将需要添加版权信息的源代码备份。
2、进入到脚本目录,修改info目录下的三个txt文件,将文件中的模块名称和作者名称修改,保存退出。然后,执行脚本:cd AddCopyrightInformation ./addInfoToAllFile.sh /home/simba/virtualshare/cmos-photos 注:参数为需要添加版权信息的模块的目录,最好是绝对路径.
3、程序执行完成之后,检查确认。
注:新建的文件,可以使用IDE自动添加。
辛巴
mac下编译go-ethereum
lansheng228赞 2阅读 3.3k
`hadoop fs -mkdir <path>` 创建的目录位置
guyu阅读 634
Flink start-cluster.sh
journey阅读 576
MySQL和MongoDB如何JOIN查询?一个直接在本地运行的SQL执行引擎
snower阅读 415
Shell在日常工作中的应用实践
京东云开发者阅读 367
Linux7上安装Oracle RAC 19C一键配置脚本(后续补充其他版本)
特立独行阅读 317
shell相关
黑暗森林阅读 302
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。