From ed26808bdf1606017950b87fdc5bbdabf18d85ae 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 | 76 ++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/tools/license-builder.sh b/tools/license-builder.sh index e6d66a037704bc..899f9de99c0610 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,85 +29,85 @@ 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/ +$//;/