From 18f21fc0a341f026de182027937cc7a5f0e0f6cf Mon Sep 17 00:00:00 2001 From: Konstantin Aladyshev Date: Sat, 30 Oct 2021 00:43:09 +0300 Subject: Add script to add license header to files Signed-off-by: Konstantin Aladyshev --- scripts/addLicense.sh | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 scripts/addLicense.sh (limited to 'scripts') diff --git a/scripts/addLicense.sh b/scripts/addLicense.sh new file mode 100755 index 0000000..890a2d2 --- /dev/null +++ b/scripts/addLicense.sh @@ -0,0 +1,56 @@ +## +# Copyright (c) 2021, Konstantin Aladyshev +# +# SPDX-License-Identifier: MIT +## + +COPYRIGHT_C="\ +/* + * Copyright (c) 2021, Konstantin Aladyshev + * + * SPDX-License-Identifier: MIT + */ +" + +COPYRIGHT_UNI="\ +// +// Copyright (c) 2021, Konstantin Aladyshev +// +// SPDX-License-Identifier: MIT +// +" + +COPYRIGHT_META="\ +## +# Copyright (c) 2021, Konstantin Aladyshev +# +# SPDX-License-Identifier: MIT +## +" + +DIR="$(dirname $(dirname "$(readlink -f "$0")"))" + +function insertCopyright { + FILENAME=${1} + COPYRIGHT=${2} + grep "Copyright" "${FILENAME}" > /dev/null + if [ $? -eq 1 ]; then + echo "${COPYRIGHT}" | cat - "${FILENAME}" > /tmp/out && mv /tmp/out "${FILENAME}"; + fi +} + +for i in $(find ${DIR} -type f -name "*.c"); +do + insertCopyright "${i}" "${COPYRIGHT_C}" +done + +for i in $(find ${DIR} -type f -name "*.uni"); +do + insertCopyright "${i}" "${COPYRIGHT_UNI}" +done + +for i in $(find ${DIR} -type f -name "*.dsc" -o -name "*.dec" -o -name "*.inf"); +do + insertCopyright "${i}" "${COPYRIGHT_META}" +done + -- cgit v1.2.3-18-g5258