From 7cc51b0ceefd37117d8b33ac4472121a90695ed2 Mon Sep 17 00:00:00 2001 From: Mark Horvath Date: Mon, 15 Jan 2024 16:12:51 +0100 Subject: [PATCH] [scripts] Fix shellcheck issues in license checker --- scripts/annotate-license.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/annotate-license.sh b/scripts/annotate-license.sh index 36c660769..c79d90d43 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 -- GitLab