From 1493054627b950afd1f7a8da45244efc94ef5544 Mon Sep 17 00:00:00 2001 From: Sercan Sahin Date: Wed, 27 Nov 2024 23:55:57 +0100 Subject: [PATCH] improve .sh file --- etc/scripts/set_copyright_year.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/etc/scripts/set_copyright_year.sh b/etc/scripts/set_copyright_year.sh index 8a3884eb..2633b190 100755 --- a/etc/scripts/set_copyright_year.sh +++ b/etc/scripts/set_copyright_year.sh @@ -10,10 +10,16 @@ # The script will check the first two lines for a copyright # notice (in case the first line is a shebang). + + while read -rd $'\0' year file; do # Extract the first year from the copyright notice current_year=$(sed -n '1,2s/^\(# Copyright (c) \)\([[:digit:]]\{4,\}\).*/\2/p' "$file") + # Skip the file if no year is found + if [[ -z "$current_year" ]]; then + continue + fi if $CHECK_MODE && [[ "$current_year" != "$year" ]]; then echo "Error: Copyright year mismatch in file $file. Expected $year, found $current_year."