[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Gavin D. Smith |
Date: |
Thu, 8 Feb 2024 15:40:22 -0500 (EST) |
branch: master
commit 553812d6da53d3d8e704ec512e2df2d3e1148b01
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Thu Feb 8 20:29:22 2024 +0000
Copyright years updating script
* grand-replace.sh: Add script. Name and idea of script comes from
GNU Lilypond.
---
ChangeLog | 7 +++++++
grand-replace.sh | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 8175937987..c428d41593 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-02-08 Gavin Smith <gavinsmith0123@gmail.com>
+
+ Copyright years updating script
+
+ * grand-replace.sh: Add script. Name and idea of script comes from
+ GNU Lilypond.
+
2024-02-08 Gavin Smith <gavinsmith0123@gmail.com>
* README-hacking: Advertise gperf dependency.
diff --git a/grand-replace.sh b/grand-replace.sh
new file mode 100755
index 0000000000..7fe6aeb5b7
--- /dev/null
+++ b/grand-replace.sh
@@ -0,0 +1,40 @@
+# grand-replace.sh - copyright years updating script
+# invoke as grand-replace.sh $dir or grand-replace.sh --list $dir
+
+list=false
+case $1 in --list)
+ list=true
+ shift;;
+esac
+
+dir=$1
+test -d "$dir" || exit 1
+cd $dir
+
+current_year=`date "+%Y"`
+prune_dirs="./tp/maintain/lib|./tp/tests/test_scripts|./gnulib|./tp/Texinfo/XS/gnulib|./js/node_modules|./contrib"
+
+prune="-regex ($prune_dirs) -prune"
+
+# Don't touch this file itself
+not="-not -name grand-replace.sh"
+
+extensions='c|h|sh|pm|pl|texi|xs'
+named_files='configure.ac|Makefile.am|README|README-hacking|TODO'
+
+ext_pattern=".*\.($extensions)"
+named_pattern=".*\/($named_files)"
+
+if $list ; then
+ find . -regextype posix-egrep $prune -o $not -type f \
+ \( -regex "$ext_pattern" -o -regex "$named_pattern" \) \
+ -print
+else
+ find . -regextype posix-egrep $prune -o $not -type f \
+ \( -regex "$ext_pattern" -o -regex "$named_pattern" \) \
+ -execdir perl -wpli -e \
+ 's/-20\d\d Free/-'$current_year' Free/;
+ s/(Copyright 20\d\d) Free/$1-'$current_year' Free/;' \
+ '{}' ';'
+fi
+