Skip to content

Commit ca875f7

Browse files
aduh95BethGriggs
authored andcommitted
tools: remove bashisms from license builder script
PR-URL: #36122 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com>
1 parent f1417eb commit ca875f7

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

tools/license-builder.sh

+36-36
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
#!/usr/bin/env bash
1+
#!/bin/sh
22

33
set -e
44

5-
rootdir="$(CDPATH= cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
rootdir="$(CDPATH='' cd "$(dirname "$0")/.." && pwd)"
66
licensefile="${rootdir}/LICENSE"
7-
licensehead="$(sed '/^- /,$d' ${licensefile})"
7+
licensehead="$(sed '/^- /,$d' "${licensefile}")"
88
tmplicense="${rootdir}/~LICENSE.$$"
9-
echo -e "$licensehead" > $tmplicense
9+
echo "$licensehead" > "$tmplicense"
1010

1111

1212
# addlicense <library> <location> <license text>
13-
function addlicense {
13+
addlicense() {
1414

1515
echo "
1616
- ${1}, located at ${2}, is licensed as follows:
1717
\"\"\"
18-
$(echo -e "$3" | sed -e 's/^/ /' -e 's/^ $//' -e 's/ *$//' | sed -e '/./,$!d' | sed -e '/^$/N;/^\n$/D')
18+
$(echo "$3" | sed -e 's/^/ /' -e 's/^ $//' -e 's/ *$//' | sed -e '/./,$!d' | sed -e '/^$/N;/^\n$/D')
1919
\"\"\"\
20-
" >> $tmplicense
20+
" >> "$tmplicense"
2121

2222
}
2323

@@ -29,79 +29,79 @@ fi
2929

3030

3131
# Dependencies bundled in distributions
32-
addlicense "Acorn" "deps/acorn" "$(cat ${rootdir}/deps/acorn/acorn/LICENSE)"
33-
addlicense "Acorn plugins" "deps/acorn-plugins" "$(cat ${rootdir}/deps/acorn-plugins/acorn-class-fields/LICENSE)"
34-
addlicense "c-ares" "deps/cares" "$(tail -n +3 ${rootdir}/deps/cares/LICENSE.md)"
35-
addlicense "cjs-module-lexer" "deps/cjs-module-lexer" "$(cat ${rootdir}/deps/cjs-module-lexer/LICENSE)"
32+
addlicense "Acorn" "deps/acorn" "$(cat "${rootdir}"/deps/acorn/acorn/LICENSE)"
33+
addlicense "Acorn plugins" "deps/acorn-plugins" "$(cat "${rootdir}"/deps/acorn-plugins/acorn-class-fields/LICENSE)"
34+
addlicense "c-ares" "deps/cares" "$(tail -n +3 "${rootdir}"/deps/cares/LICENSE.md)"
35+
addlicense "cjs-module-lexer" "deps/cjs-module-lexer" "$(cat "${rootdir}"/deps/cjs-module-lexer/LICENSE)"
3636
if [ -f "${rootdir}/deps/icu/LICENSE" ]; then
3737
# ICU 57 and following. Drop the BOM
3838
addlicense "ICU" "deps/icu" \
3939
"$(sed -e '1s/^[^a-zA-Z ]*ICU/ICU/' -e :a \
40-
-e 's/<[^>]*>//g;s/ / /g;s/ +$//;/</N;//ba' ${rootdir}/deps/icu/LICENSE)"
40+
-e 's/<[^>]*>//g;s/ / /g;s/ +$//;/</N;//ba' "${rootdir}"/deps/icu/LICENSE)"
4141
elif [ -f "${rootdir}/deps/icu/license.html" ]; then
4242
# ICU 56 and prior
4343
addlicense "ICU" "deps/icu" \
4444
"$(sed -e '1,/ICU License - ICU 1\.8\.1 and later/d' -e :a \
45-
-e 's/<[^>]*>//g;s/ / /g;s/ +$//;/</N;//ba' ${rootdir}/deps/icu/license.html)"
45+
-e 's/<[^>]*>//g;s/ / /g;s/ +$//;/</N;//ba' "${rootdir}"/deps/icu/license.html)"
4646
elif [ -f "${rootdir}/deps/icu-small/LICENSE" ]; then
4747
# ICU 57 and following. Drop the BOM
4848
addlicense "ICU" "deps/icu-small" \
4949
"$(sed -e '1s/^[^a-zA-Z ]*ICU/ICU/' -e :a \
50-
-e 's/<[^>]*>//g;s/ / /g;s/ +$//;/</N;//ba' ${rootdir}/deps/icu-small/LICENSE)"
50+
-e 's/<[^>]*>//g;s/ / /g;s/ +$//;/</N;//ba' "${rootdir}"/deps/icu-small/LICENSE)"
5151
elif [ -f "${rootdir}/deps/icu-small/license.html" ]; then
5252
# ICU 56 and prior
5353
addlicense "ICU" "deps/icu-small" \
5454
"$(sed -e '1,/ICU License - ICU 1\.8\.1 and later/d' -e :a \
55-
-e 's/<[^>]*>//g;s/ / /g;s/ +$//;/</N;//ba' ${rootdir}/deps/icu-small/license.html)"
55+
-e 's/<[^>]*>//g;s/ / /g;s/ +$//;/</N;//ba' "${rootdir}"/deps/icu-small/license.html)"
5656
else
5757
echo "Could not find an ICU license file."
5858
exit 1
5959
fi
6060

61-
addlicense "libuv" "deps/uv" "$(cat ${rootdir}/deps/uv/LICENSE)"
61+
addlicense "libuv" "deps/uv" "$(cat "${rootdir}"/deps/uv/LICENSE)"
6262
addlicense "llhttp" "deps/llhttp" "$(cat deps/llhttp/LICENSE-MIT)"
6363
addlicense "OpenSSL" "deps/openssl" \
64-
"$(sed -e '/^ \*\/$/,$d' -e '/^ [^*].*$/d' -e '/\/\*.*$/d' -e '/^$/d' -e 's/^[/ ]\* *//' ${rootdir}/deps/openssl/openssl/LICENSE)"
64+
"$(sed -e '/^ \*\/$/,$d' -e '/^ [^*].*$/d' -e '/\/\*.*$/d' -e '/^$/d' -e 's/^[/ ]\* *//' "${rootdir}"/deps/openssl/openssl/LICENSE)"
6565
addlicense "Punycode.js" "lib/punycode.js" \
6666
"$(curl -sL https://raw.githubusercontent.com/bestiejs/punycode.js/master/LICENSE-MIT.txt)"
67-
addlicense "V8" "deps/v8" "$(cat ${rootdir}/deps/v8/LICENSE)"
67+
addlicense "V8" "deps/v8" "$(cat "${rootdir}"/deps/v8/LICENSE)"
6868
addlicense "SipHash" "deps/v8/src/third_party/siphash" \
6969
"$(sed -e '/You should have received a copy of the CC0/,$d' -e 's/^\/\* *//' -e 's/^ \* *//' deps/v8/src/third_party/siphash/halfsiphash.cc)"
7070
addlicense "zlib" "deps/zlib" \
71-
"$(sed -e '/The data format used by the zlib library/,$d' -e 's/^\/\* *//' -e 's/^ *//' ${rootdir}/deps/zlib/zlib.h)"
71+
"$(sed -e '/The data format used by the zlib library/,$d' -e 's/^\/\* *//' -e 's/^ *//' "${rootdir}"/deps/zlib/zlib.h)"
7272

7373
# npm
74-
addlicense "npm" "deps/npm" "$(cat ${rootdir}/deps/npm/LICENSE)"
74+
addlicense "npm" "deps/npm" "$(cat "${rootdir}"/deps/npm/LICENSE)"
7575

7676
# Build tools
77-
addlicense "GYP" "tools/gyp" "$(cat ${rootdir}/tools/gyp/LICENSE)"
78-
addlicense "inspector_protocol" "tools/inspector_protocol" "$(cat ${rootdir}/tools/inspector_protocol/LICENSE)"
79-
addlicense "jinja2" "tools/inspector_protocol/jinja2" "$(cat ${rootdir}/tools/inspector_protocol/jinja2/LICENSE)"
80-
addlicense "markupsafe" "tools/inspector_protocol/markupsafe" "$(cat ${rootdir}/tools/inspector_protocol/markupsafe/LICENSE)"
77+
addlicense "GYP" "tools/gyp" "$(cat "${rootdir}"/tools/gyp/LICENSE)"
78+
addlicense "inspector_protocol" "tools/inspector_protocol" "$(cat "${rootdir}"/tools/inspector_protocol/LICENSE)"
79+
addlicense "jinja2" "tools/inspector_protocol/jinja2" "$(cat "${rootdir}"/tools/inspector_protocol/jinja2/LICENSE)"
80+
addlicense "markupsafe" "tools/inspector_protocol/markupsafe" "$(cat "${rootdir}"/tools/inspector_protocol/markupsafe/LICENSE)"
8181

8282
# Testing tools
8383
addlicense "cpplint.py" "tools/cpplint.py" \
84-
"$(sed -e '/^$/,$d' -e 's/^#$//' -e 's/^# //' ${rootdir}/tools/cpplint.py | tail -n +3)"
85-
addlicense "ESLint" "tools/node_modules/eslint" "$(cat ${rootdir}/tools/node_modules/eslint/LICENSE)"
86-
addlicense "babel-eslint" "tools/node_modules/babel-eslint" "$(cat ${rootdir}/tools/node_modules/babel-eslint/LICENSE)"
87-
addlicense "gtest" "test/cctest/gtest" "$(cat ${rootdir}/test/cctest/gtest/LICENSE)"
84+
"$(sed -e '/^$/,$d' -e 's/^#$//' -e 's/^# //' "${rootdir}"/tools/cpplint.py | tail -n +3)"
85+
addlicense "ESLint" "tools/node_modules/eslint" "$(cat "${rootdir}"/tools/node_modules/eslint/LICENSE)"
86+
addlicense "babel-eslint" "tools/node_modules/babel-eslint" "$(cat "${rootdir}"/tools/node_modules/babel-eslint/LICENSE)"
87+
addlicense "gtest" "test/cctest/gtest" "$(cat "${rootdir}"/test/cctest/gtest/LICENSE)"
8888

8989
# nghttp2
90-
addlicense "nghttp2" "deps/nghttp2" "$(cat ${rootdir}/deps/nghttp2/COPYING)"
90+
addlicense "nghttp2" "deps/nghttp2" "$(cat "${rootdir}"/deps/nghttp2/COPYING)"
9191

9292
# node-inspect
93-
addlicense "node-inspect" "deps/node-inspect" "$(cat ${rootdir}/deps/node-inspect/LICENSE)"
93+
addlicense "node-inspect" "deps/node-inspect" "$(cat "${rootdir}"/deps/node-inspect/LICENSE)"
9494

9595
# large_pages
96-
addlicense "large_pages" "src/large_pages" "$(sed -e '/SPDX-License-Identifier/,$d' -e 's/^\/\///' ${rootdir}/src/large_pages/node_large_page.h)"
96+
addlicense "large_pages" "src/large_pages" "$(sed -e '/SPDX-License-Identifier/,$d' -e 's/^\/\///' "${rootdir}"/src/large_pages/node_large_page.h)"
9797

9898
# deep_freeze
99-
addlicense "caja" "lib/internal/freeze_intrinsics.js" "$(sed -e '/SPDX-License-Identifier/,$d' -e 's/^\/\///' ${rootdir}/lib/internal/freeze_intrinsics.js)"
99+
addlicense "caja" "lib/internal/freeze_intrinsics.js" "$(sed -e '/SPDX-License-Identifier/,$d' -e 's/^\/\///' "${rootdir}"/lib/internal/freeze_intrinsics.js)"
100100

101101
# brotli
102-
addlicense "brotli" "deps/brotli" "$(cat ${rootdir}/deps/brotli/LICENSE)"
102+
addlicense "brotli" "deps/brotli" "$(cat "${rootdir}"/deps/brotli/LICENSE)"
103103

104-
addlicense "HdrHistogram" "deps/histogram" "$(cat ${rootdir}/deps/histogram/LICENSE.txt)"
104+
addlicense "HdrHistogram" "deps/histogram" "$(cat "${rootdir}"/deps/histogram/LICENSE.txt)"
105105

106106
addlicense "highlight.js" "doc/api_assets/highlight.pack.js" \
107107
"$(curl -sL https://raw.githubusercontent.com/highlightjs/highlight.js/63f367c46f2eeb6f9b7a3545e325eeeb917f9942/LICENSE)"
@@ -112,6 +112,6 @@ addlicense "node-heapdump" "src/heap_utils.cc" \
112112
addlicense "rimraf" "lib/internal/fs/rimraf.js" \
113113
"$(curl -sL https://raw.githubusercontent.com/isaacs/rimraf/0e365ac4e4d64a25aa2a3cc026348f13410210e1/LICENSE)"
114114

115-
addlicense "uvwasi" "deps/uvwasi" "$(cat ${rootdir}/deps/uvwasi/LICENSE)"
115+
addlicense "uvwasi" "deps/uvwasi" "$(cat "${rootdir}"/deps/uvwasi/LICENSE)"
116116

117-
mv $tmplicense $licensefile
117+
mv "$tmplicense" "$licensefile"

0 commit comments

Comments
 (0)