diff options
author | P. J. McDermott <pj@pehjota.net> | 2017-07-22 18:49:50 (EDT) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2017-07-22 18:49:50 (EDT) |
commit | 5f885537e29ecd6b63b50f8374799c8604e486be (patch) | |
tree | c29514dfd7a0ba6a6c93f05e38f2efd64c7df863 | |
parent | fd9cec7179acb5e0ab5935aeb04e2afd1f362f39 (diff) |
scripts/update-license-notice.sh: Rewrite in native SCL (works now)
-rwxr-xr-x | scripts/update-license-notice.sh | 30 |
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 |