#- # This file is part of Clide. # # Clide is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Clide is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Clide. If not, see . # #!/bin/sh __help() { echo '' } __update_copyright() { local YEAR=$(date +%Y) local COPYRIGHT=copyright.txt # Filename of the copyright to append to the source code # Extension, to know wich symbol to use for the copyright local EXTENSION="${1##*.}" case $EXTENSION in java|c|h) local START='/*-'; local END=' */'; local ROW=' \*';; properties) local START='#-'; local END='#'; local ROW='#' ;; Makefile) local START='#-'; local END='#'; local ROW='#' ;; esac # This is the range between the start and the end of the copyright header local RANGE=$(echo $(cat $1 | grep -n "^$START$\|^$END$" | head -2 | sed -E 's/([0-9]+):.*/\1/g') | tr ' ', ',') if [ -z $RANGE ]; then # If the range is empty, copyright notice must be added RANGE=0a local ADD_BLANK_LINE=1 else # Otherwise must be replaced RANGE=${RANGE}c fi # Generate the content with local CONTENT=$(cat $COPYRIGHT \ | sed "s/%YEAR%/$YEAR/g" \ | sed -E "s/^(.+)/$ROW \1/g" | sed -E "s/^$/$ROW/g") if [ ! -z $ADD_BLANK_LINE ]; then ed "$1" <