azure-storage-fuse/copyright_fix.sh

54 строки
1.4 KiB
Bash
Исходник Обычный вид История

2022-02-09 19:42:28 +03:00
#!/bin/bash
currYear=`date +"%Y"`
searchStr="Copyright ©"
copyLine=`grep -h $searchStr LICENSE`
if [[ "$1" == "replace" ]]
then
for i in $(find -name \*.go); do
2022-02-09 19:42:28 +03:00
result=$(grep "$searchStr" $i)
if [ $? -ne 1 ]
then
echo "Replacing in $i"
result=$(grep "+build" $i)
2022-02-09 19:42:28 +03:00
if [ $? -ne 1 ]
then
sed -i -e '5,32{R LICENSE' -e 'd}' $i
2022-02-09 19:42:28 +03:00
else
sed -i -e '2,31{R LICENSE' -e 'd}' $i
fi
fi
done
else
for i in $(find -name \*.go); do
result=$(grep "$searchStr" $i)
if [ $? -eq 1 ]
then
echo "Adding Copyright to $i"
result=$(grep "+build" $i)
if [ $? -ne 1 ]
2022-02-09 19:42:28 +03:00
then
echo $result > __temp__
echo -n >> __temp__
echo "/*" >> __temp__
cat LICENSE >> __temp__
echo -e "*/" >> __temp__
tail -n+2 $i >> __temp__
else
2022-02-09 19:42:28 +03:00
echo "/*" > __temp__
cat LICENSE >> __temp__
echo -e "*/\n" >> __temp__
2022-02-09 19:42:28 +03:00
cat $i >> __temp__
fi
mv __temp__ $i
else
currYear_found=$(echo $result | grep $currYear)
if [ $? -eq 1 ]
then
echo "Updating Copyright in $i"
sed -i "/$searchStr/c\\$copyLine" $i
2022-02-09 19:42:28 +03:00
fi
fi
done
fi