summaryrefslogtreecommitdiffstats
path: root/scripts/update-license-notice.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/update-license-notice.sh')
-rwxr-xr-xscripts/update-license-notice.sh30
1 files changed, 19 insertions, 11 deletions
diff --git a/scripts/update-license-notice.sh b/scripts/update-license-notice.sh
index 80b2ff8..e139b02 100755
--- a/scripts/update-license-notice.sh
+++ b/scripts/update-license-notice.sh
@@ -18,7 +18,9 @@
set -eu
-cat >license-notice.txt <<-'EOF'
+LF='
+'
+NEW_NOTICE="$(cat <<-'EOF'
# This file is part of the ProteanOS Archive Manager.
#
# The ProteanOS Archive Manager is free software: you can redistribute
@@ -35,20 +37,26 @@ cat >license-notice.txt <<-'EOF'
# along with the ProteanOS Archive Manager. If not, see
# <http://www.gnu.org/licenses/>.
EOF
+ )"
if [ ${#} -eq 0 ]; then
printf 'Usage: %s <file>...\n' "${0}" >&2
fi
-gnu_lic_url='<http:\/\/www.gnu.org\/licenses\/>'
for file in "${@}"; do
- sed '
- /This program is free software:/,/'"${gnu_lic_url}"'/{
- d
- r license-notice.txt
- }
- ' "${file}" >"${file}~"
- mv "${file}~" "${file}"
+ text=''
+ while IFS= read -r line; do
+ case "${line}" in '# This program is free software:'*)
+ while IFS= read -r notice; do
+ case "${notice}" in
+ *'<http://www.gnu.org/licenses/>.')
+ text="${text}${NEW_NOTICE}${LF}"
+ break;
+ ;;
+ esac
+ done
+ ;; esac
+ text="${text}${line}${LF}"
+ done <"${file}"
+ printf '%s' "${text}" >"${file}"
done
-
-rm -f license-notice.txt