From 227fc2bc7dcd9ebc328634dc421373624ba22cc2 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 4 Aug 2021 03:50:04 +0800 Subject: [PATCH] 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 --- mkdumprd | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/mkdumprd b/mkdumprd index 8687b30..c7538a9 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 @@ -428,7 +428,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)" ;; *) ;; @@ -439,7 +441,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 @@ -455,7 +457,7 @@ if ! is_fadump_capable; then add_dracut_arg "--no-hostonly-default-device" fi -echo "$dracut_args $@" | xargs dracut +dracut "${dracut_args[@]}" "$@" _rc=$? sync