From: Benjamin Drung Date: Fri, 31 Oct 2025 12:38:25 +0000 (+0100) Subject: test(run-qemu): quote arguments only if needed X-Git-Tag: 109~12 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=69aa5290f5bbb258dcd42421ece22ca0a8afe696;p=thirdparty%2Fdracut-ng.git test(run-qemu): quote arguments only if needed Increase the readability of the qemu call log by quoting the arguments only if needed. --- diff --git a/test/run-qemu b/test/run-qemu index 7e95816cd..073d69b18 100755 --- a/test/run-qemu +++ b/test/run-qemu @@ -7,6 +7,18 @@ export PATH=/usr/sbin:/usr/bin:/sbin:/bin ARCH="${ARCH-$(uname -m)}" QEMU_CPU="${QEMU_CPU:-max}" +quote_args() { + local arg args=() + for arg in "$@"; do + if [[ -z $arg || $arg =~ [[:space:]\'] ]]; then + args+=("'${arg//\'/\'\\\'\'}'") + else + args+=("$arg") + fi + done + echo "${args[*]}" +} + set_vmlinux_env() { if [[ ${KVERSION-} ]]; then VMLINUZ=${VMLINUZ-"/lib/modules/${KVERSION}/vmlinuz"} @@ -104,5 +116,5 @@ if [[ $* == *-initrd* ]]; then ARGS+=(-kernel "$VMLINUZ") fi -echo "${0##*/}: $BIN ${ARGS[*]@Q} ${*@Q}" +echo "${0##*/}: $BIN $(quote_args "${ARGS[@]}") $(quote_args "$@")" exec "$BIN" "${ARGS[@]}" "$@"