From dd08f1bddda88348fcce8a59922cb17909a2b801 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Wed, 3 Nov 2021 15:32:36 +0800 Subject: [PATCH] mkdumprd: make dracut_args an array again upstream: fedora resolves: bz2003832 conflict: none commit 227fc2bc7dcd9ebc328634dc421373624ba22cc2 Author: Kairui Song Date: Wed Aug 4 03:50:04 2021 +0800 mkdumprd: make dracut_args an array again To make arguments list work as expected, array is preferred. Use xargs only to parse the "dracut_args" config value, and pass the array directly to dracut. Check following link for details: https://github.com/koalaman/shellcheck/wiki/SC2089 Signed-off-by: Kairui Song Acked-by: Philipp Rudo Signed-off-by: Tao Liu --- mkdumprd | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/mkdumprd b/mkdumprd index d40f3ca..b866a9b 100644 --- a/mkdumprd +++ b/mkdumprd @@ -28,7 +28,7 @@ SAVE_PATH=$(get_save_path) OVERRIDE_RESETTABLE=0 extra_modules="" -dracut_args="--add kdumpbase --quiet --hostonly --hostonly-cmdline --hostonly-i18n --hostonly-mode strict -o \"plymouth dash resume ifcfg earlykdump\"" +dracut_args=( --add kdumpbase --quiet --hostonly --hostonly-cmdline --hostonly-i18n --hostonly-mode strict -o "plymouth dash resume ifcfg earlykdump" ) readonly MKDUMPRD_TMPDIR="$(mktemp -d -t mkdumprd.XXXXXX)" [ -d "$MKDUMPRD_TMPDIR" ] || perror_exit "dracut: mktemp -p -d -t dracut.XXXXXX failed." @@ -45,15 +45,15 @@ trap ' trap 'exit 1;' SIGINT add_dracut_arg() { - dracut_args="$dracut_args $@" + dracut_args+=( "$@" ) } add_dracut_mount() { - add_dracut_arg "--mount" "\"$1\"" + add_dracut_arg "--mount" "$1" } add_dracut_sshkey() { - add_dracut_arg "--sshkey" "\"$1\"" + add_dracut_arg "--sshkey" "$1" } # caller should ensure $1 is valid and mounted in 1st kernel @@ -408,7 +408,9 @@ do verify_core_collector "$config_val" ;; dracut_args) - add_dracut_arg $config_val + while read -r dracut_arg; do + add_dracut_arg "$dracut_arg" + done <<< "$(echo "$config_val" | xargs -n 1 echo)" ;; *) ;; @@ -419,7 +421,7 @@ handle_default_dump_target if [ -n "$extra_modules" ] then - add_dracut_arg "--add-drivers" \"$extra_modules\" + add_dracut_arg "--add-drivers" "$extra_modules" fi # TODO: The below check is not needed anymore with the introduction of @@ -435,7 +437,7 @@ if ! is_fadump_capable; then add_dracut_arg "--no-hostonly-default-device" fi -echo "$dracut_args $@" | xargs dracut +dracut "${dracut_args[@]}" "$@" _rc=$? sync