From 75e49b833b933752d88fcfd222c3a2d335178fc9 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sat, 14 Nov 2020 18:37:50 +0100 Subject: [PATCH] tools: remove bashisms from license builder script PR-URL: https://github.com/nodejs/node/pull/36122 Reviewed-By: Rich Trott Reviewed-By: Richard Lau --- tools/license-builder.sh | 72 ++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/tools/license-builder.sh b/tools/license-builder.sh index 50f4474c644441..e001e87a4f2250 100755 --- a/tools/license-builder.sh +++ b/tools/license-builder.sh @@ -1,23 +1,23 @@ -#!/usr/bin/env bash +#!/bin/sh set -e -rootdir="$(CDPATH= cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +rootdir="$(CDPATH='' cd "$(dirname "$0")/.." && pwd)" licensefile="${rootdir}/LICENSE" -licensehead="$(sed '/^- /,$d' ${licensefile})" +licensehead="$(sed '/^- /,$d' "${licensefile}")" tmplicense="${rootdir}/~LICENSE.$$" -echo -e "$licensehead" > $tmplicense +echo "$licensehead" > "$tmplicense" # addlicense -function addlicense { +addlicense() { echo " - ${1}, located at ${2}, is licensed as follows: \"\"\" -$(echo -e "$3" | sed -e 's/^/ /' -e 's/^ $//' -e 's/ *$//' | sed -e '/./,$!d' | sed -e '/^$/N;/^\n$/D') +$(echo "$3" | sed -e 's/^/ /' -e 's/^ $//' -e 's/ *$//' | sed -e '/./,$!d' | sed -e '/^$/N;/^\n$/D') \"\"\"\ -" >> $tmplicense +" >> "$tmplicense" } @@ -29,79 +29,79 @@ fi # Dependencies bundled in distributions -addlicense "Acorn" "deps/acorn" "$(cat ${rootdir}/deps/acorn/acorn/LICENSE)" -addlicense "Acorn plugins" "deps/acorn-plugins" "$(cat ${rootdir}/deps/acorn-plugins/acorn-class-fields/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)" +addlicense "Acorn" "deps/acorn" "$(cat "${rootdir}"/deps/acorn/acorn/LICENSE)" +addlicense "Acorn plugins" "deps/acorn-plugins" "$(cat "${rootdir}"/deps/acorn-plugins/acorn-class-fields/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)" 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/ +$//;/]*>//g;s/ / /g;s/ +$//;/]*>//g;s/ / /g;s/ +$//;/]*>//g;s/ / /g;s/ +$//;/]*>//g;s/ / /g;s/ +$//;/