diff --git a/scripts/annotate-license.sh b/scripts/annotate-license.sh index 36c660769c0bbeb92c098530129014d4370c35bc..c79d90d434aa1ff3381e0f5bf853af550d2ed2e5 100755 --- a/scripts/annotate-license.sh +++ b/scripts/annotate-license.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # SPDX-FileCopyrightText: 2023 Arm Limited and/or its affiliates # @@ -18,6 +18,8 @@ # If any changes has been made as a result of running this script the user will # be asked to add changes to commit. +set -eu + RED='\033[0;31m' GREEN='\033[0;32m' NC='\033[0m' # No Color @@ -30,19 +32,19 @@ LICENSE="Apache-2.0" # unrecognised formats annotate() { local file=$1 - out=$(reuse annotate -c "$COPYRIGHT" --license "$LICENSE" --merge-copyrights $file 2> >(cat)) + out=$(reuse annotate -c "$COPYRIGHT" --license "$LICENSE" --merge-copyrights "$file" 2> >(cat)) if [ $? -eq 2 ]; then echo -e "${RED}Failed to annotate $file, enforcing c-style comment${NC}" - reuse annotate -c "$COPYRIGHT" --license "$LICENSE" --merge-copyrights --style c $file + reuse annotate -c "$COPYRIGHT" --license "$LICENSE" --merge-copyrights --style c "$file" else - echo $out + echo "$out" fi } UNSTAGED=$(git diff --name-only) STAGED=$(git diff --cached --name-only) for file in $STAGED; do - annotate $file + annotate "$file" done # Run license check on the entire codebase