From 60c059e4bc8c0664b4408c516454d00e36667d59 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 22 Dec 2021 06:38:13 -0800 Subject: [PATCH] tools: make license-builder.sh comply with shellcheck 0.8.0 Fixes for SC2312 added in shellcheck 0.8.0. PR-URL: https://github.com/nodejs/node/pull/41258 Reviewed-By: James M Snell Reviewed-By: Mohammed Keyvanzadeh --- tools/license-builder.sh | 124 +++++++++++++++++++++++---------------- 1 file changed, 72 insertions(+), 52 deletions(-) diff --git a/tools/license-builder.sh b/tools/license-builder.sh index 1fd1dd599e9309..31c525c0ec4a64 100755 --- a/tools/license-builder.sh +++ b/tools/license-builder.sh @@ -11,11 +11,12 @@ echo "$licensehead" > "$tmplicense" # addlicense addlicense() { + licenseTextTrimmed=$(echo "$3" | sed -e 's/^/ /' -e 's/^ $//' -e 's/ *$//' | sed -e '/./,$!d' | sed -e '/^$/N;/^\n$/D') echo " - ${1}, located at ${2}, is licensed as follows: \"\"\" -$(echo "$3" | sed -e 's/^/ /' -e 's/^ $//' -e 's/ *$//' | sed -e '/./,$!d' | sed -e '/^$/N;/^\n$/D') +${licenseTextTrimmed} \"\"\"\ " >> "$tmplicense" @@ -29,89 +30,108 @@ fi # Dependencies bundled in distributions -addlicense "Acorn" "deps/acorn" "$(cat "${rootdir}"/deps/acorn/acorn/LICENSE)" -addlicense "c-ares" "deps/cares" "$(tail -n +3 "${rootdir}"/deps/cares/LICENSE.md)" -addlicense "cjs-module-lexer" "deps/cjs-module-lexer" "$(cat "${rootdir}"/deps/cjs-module-lexer/LICENSE)" +licenseText="$(cat "${rootdir}"/deps/acorn/acorn/LICENSE)" +addlicense "Acorn" "deps/acorn" "$licenseText" +licenseText="$(tail -n +3 "${rootdir}"/deps/cares/LICENSE.md)" +addlicense "c-ares" "deps/cares" "$licenseText" +licenseText="$(cat "${rootdir}"/deps/cjs-module-lexer/LICENSE)" +addlicense "cjs-module-lexer" "deps/cjs-module-lexer" "$licenseText" if [ -f "${rootdir}/deps/icu/LICENSE" ]; then # ICU 57 and following. Drop the BOM - addlicense "ICU" "deps/icu" \ - "$(sed -e '1s/^[^a-zA-Z ]*ICU/ICU/' -e :a \ - -e 's/<[^>]*>//g;s/ / /g;s/ +$//;/]*>//g;s/ / /g;s/ +$//;/]*>//g;s/ / /g;s/ +$//;/]*>//g;s/ / /g;s/ +$//;/