summaryrefslogtreecommitdiff
path: root/noide
diff options
context:
space:
mode:
Diffstat (limited to 'noide')
-rwxr-xr-xnoide53
1 files changed, 53 insertions, 0 deletions
diff --git a/noide b/noide
index fffffa4..80bdd32 100755
--- a/noide
+++ b/noide
@@ -1,5 +1,6 @@
#!/bin/sh
+#-
# Copyright (c) 2023, Alessandro Iezzi
#
# Redistribution and use in source and binary forms, with or without
@@ -23,3 +24,55 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+update_copyright()
+{
+ if [ -z $1 ]; then
+ echo "$0 --update-copyright <file>"
+ exit 1
+ fi
+
+ ifile=$1
+ ffile=license-header.txt
+ ofile=tmp`date +%s`-2
+ ftype="`file $1 | sed -E 's/.*: (.*),.*/\1/g'`"
+ tmpfile=tmp`date +%s`-1
+
+ if [ "$ftype" = 'C source' ]; then
+ s="\/\*-"
+ m=" \*"
+ e=" \*\/"
+ elif [ "$ftype" = 'makefile script' ]; then
+ s="#-"
+ m="#"
+ e=""
+ elif [ "$ftype" = 'POSIX shell script' ]; then
+ s="#-"
+ m="#"
+ e=""
+ else
+ echo "Unknown file type"
+ exit 1
+ fi
+
+ printf "%s\n" $s | sed 's/\\//g' > $tmpfile
+ cat $ffile | sed "s/^/$m /g" | sed "s/^$m $/$m/g" >> $tmpfile
+ printf "$e\n" | sed 's/\\//g' >> $tmpfile
+
+ sed "
+ /^$s/r "$tmpfile"
+ /^$s/,/^$e$/d
+ " <"$ifile" >"$ofile"
+
+ mv $ofile $ifile
+
+ rm $tmpfile
+}
+
+while [ $# -gt ]; do
+ case $1 in
+ --update-copyright)
+ update_copyright $@
+ ;;
+ esac
+ shift
+done