[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 6/9] configure: Don't use bash-specific string-replacement syntax
From: |
Peter Maydell |
Subject: |
[PULL 6/9] configure: Don't use bash-specific string-replacement syntax |
Date: |
Tue, 26 Jul 2022 16:20:09 +0100 |
The variable string-replacement syntax ${var/old/new} is a bashism
(though it is also supported by some other shells), and for instance
does not work with the NetBSD /bin/sh, which complains:
../src/configure: 687: Syntax error: Bad substitution
Replace it with a more portable sed-based approach, similar to
what we already do in quote_sh().
Note that shellcheck also diagnoses this:
In ./configure line 687:
e=${e/'\'/'\\'}
^-----------^ SC2039: In POSIX sh, string replacement is undefined.
^-- SC1003: Want to escape a single quote? echo 'This is how it'\''s
done'.
^-- SC1003: Want to escape a single quote? echo 'This is how
it'\''s done'.
In ./configure line 688:
e=${e/\"/'\"'}
^----------^ SC2039: In POSIX sh, string replacement is undefined.
Fixes: 8154f5e64b0cf ("meson: Prefix each element of firmware path")
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Tested-by: Thomas Huth <thuth@redhat.com>
Message-id: 20220720152631.450903-4-peter.maydell@linaro.org
---
configure | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/configure b/configure
index a56c3d921be..c05205b6085 100755
--- a/configure
+++ b/configure
@@ -684,9 +684,10 @@ meson_option_build_array() {
IFS=:
fi
for e in $1; do
- e=${e/'\'/'\\'}
- e=${e/\"/'\"'}
- printf '"""%s""",' "$e"
+ printf '"""'
+ # backslash escape any '\' and '"' characters
+ printf "%s" "$e" | sed -e 's/\([\"]\)/\\\1/g'
+ printf '""",'
done)
printf ']\n'
}
--
2.25.1
- [PULL 8/9] target/arm: Correctly implement Feat_DoubleLock, (continued)
- [PULL 8/9] target/arm: Correctly implement Feat_DoubleLock, Peter Maydell, 2022/07/07
- Re: [PULL 0/9] target-arm queue, Richard Henderson, 2022/07/07
- [PULL 0/9] target-arm queue, Peter Maydell, 2022/07/26
- [PULL 1/9] scripts/coverity-scan/COMPONENTS.md: Add loongarch component, Peter Maydell, 2022/07/26
- [PULL 2/9] scripts/coverity-scan/COMPONENTS.md: Update slirp component info, Peter Maydell, 2022/07/26
- [PULL 8/9] configure: Avoid '==' bashism, Peter Maydell, 2022/07/26
- [PULL 3/9] target/arm: Add MO_128 entry to pred_esz_masks[], Peter Maydell, 2022/07/26
- [PULL 7/9] configure: Drop dead code attempting to use -msmall-data on alpha hosts, Peter Maydell, 2022/07/26
- [PULL 4/9] configure: Add missing POSIX-required space, Peter Maydell, 2022/07/26
- [PULL 5/9] configure: Add braces to clarify intent of $emu[[:space:]], Peter Maydell, 2022/07/26
- [PULL 6/9] configure: Don't use bash-specific string-replacement syntax,
Peter Maydell <=
- [PULL 9/9] hw/display/bcm2835_fb: Fix framebuffer allocation address, Peter Maydell, 2022/07/26
- Re: [PULL 0/9] target-arm queue, Richard Henderson, 2022/07/26