diff options
Diffstat (limited to 'tools/meson-apply-m4.sh')
-rwxr-xr-x | tools/meson-apply-m4.sh | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/tools/meson-apply-m4.sh b/tools/meson-apply-m4.sh index 7b4801ff94..35d8d159ef 100755 --- a/tools/meson-apply-m4.sh +++ b/tools/meson-apply-m4.sh @@ -1,25 +1,21 @@ -#!/bin/sh +#!/bin/bash # SPDX-License-Identifier: LGPL-2.1-or-later set -eu -CONFIG=$1 -TARGET=$2 +CONFIG="${1:?Missing path to config.h}" +TARGET="${2:?Missing target m4 file}" -if [ $# -ne 2 ]; then - echo 'Invalid number of arguments.' - exit 1 -fi - -if [ ! -f $CONFIG ]; then +if [ ! -f "$CONFIG" ]; then echo "$CONFIG not found." exit 2 fi -if [ ! -f $TARGET ]; then +if [ ! -f "$TARGET" ]; then echo "$TARGET not found." exit 3 fi -DEFINES=$(awk '$1 == "#define" && $3 == "1" { printf "-D%s ", $2 }' $CONFIG) +DEFINES=() +mapfile -t DEFINES < <(awk '$1 == "#define" && $3 == "1" { printf "-D%s\n", $2 }' "$CONFIG") -m4 -P $DEFINES $TARGET +m4 -P "${DEFINES[@]}" "$TARGET" |