Skip to content

Commit 130dfcf

Browse files
iavclaude
andcommitted
extensions: allwinner-kernel-bump: quote variables in destructive commands (#9400 P0)
Quote ${patch_dir_base}, ${patch_dir_megous}, ${patch_dir_tmp}, ${kernel_work_dir}, ${bundle_file}, ${PREV_KERNEL_PATCH_DIR} in rm, cp, mv, mkdir, git, grep, sed -i, and cat commands. Fix unquoted array expansion: ${megous_trees[@]} → "${megous_trees[@]}". Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7372d76 commit 130dfcf

1 file changed

Lines changed: 18 additions & 18 deletions

File tree

extensions/allwinner-kernel-bump.sh

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ function extension_finish_config__prepare_megous_patches() {
3535
patch_dir_megous="${patch_dir_base}/patches.megous"
3636
patch_dir_tmp="${patch_dir_base}/patches.megi"
3737

38-
if [[ -d ${patch_dir_base} ]]; then
38+
if [[ -d "${patch_dir_base}" ]]; then
3939
display_alert "allwinner-kernel-bump" "Found existing kernel patch directory" "info"
4040
if [[ "${OVERWRITE_PATCHDIR:-no}" == "yes" ]]; then
4141
display_alert "allwinner-kernel-bump" "Removing as requested. Any manual changes will get overwritten" "info"
42-
rm -rf ${patch_dir_base}
42+
rm -rf "${patch_dir_base}"
4343
else
4444
display_alert "allwinner-kernel-bump" "Skipping kernel patch directory creation" "info"
4545
return 0
@@ -59,38 +59,38 @@ function extension_finish_config__prepare_megous_patches() {
5959
run_host_command_logged mkdir -pv "${git_bundles_dir}"
6060
run_host_command_logged rm "${bundle_file}" || true
6161
do_with_retries 5 axel "--output=${bundle_file}" "${bundle_url}"
62-
run_host_command_logged git -C ${kernel_work_dir} fetch ${bundle_file} '+refs/heads/*:refs/remotes/megous/*'
62+
run_host_command_logged git -C "${kernel_work_dir}" fetch "${bundle_file}" '+refs/heads/*:refs/remotes/megous/*'
6363

6464
display_alert "allwinner-kernel-bump" "Initializing kernel patch directory using previous kernel patch dir" "info"
65-
run_host_command_logged cp -aR ${PREV_KERNEL_PATCH_DIR} ${patch_dir_base}
65+
run_host_command_logged cp -aR "${PREV_KERNEL_PATCH_DIR}" "${patch_dir_base}"
6666

6767
# Removing older copy of megous patches and series.conf file
68-
run_host_command_logged rm -rf ${patch_dir_base}/patches.megous/*
69-
run_host_command_logged rm -f ${patch_dir_base}/series.{conf,megous}
68+
run_host_command_logged rm -rf "${patch_dir_base}"/patches.megous/*
69+
run_host_command_logged rm -f "${patch_dir_base}"/series.{conf,megous}
7070

7171
display_alert "allwinner-kernel-bump" "Extracting latest Megous patches" "info"
7272
megous_trees=("a83t-suspend" "af8133j" "anx" "audio" "axp" "cam" "drm"
7373
"err" "fixes" "mbus" "modem" "opi3" "pb" "pinetab" "pp" "ppkb" "samuel"
7474
"speed" "tbs-a711" "ths")
7575

76-
run_host_command_logged mkdir -p ${patch_dir_megous} ${patch_dir_tmp}
76+
run_host_command_logged mkdir -p "${patch_dir_megous}" "${patch_dir_tmp}"
7777

78-
for tree in ${megous_trees[@]}; do
79-
run_host_command_logged "${SRC}"/tools/mk_format_patch ${kernel_work_dir} master..megous/${tree}-${KERNEL_MAJOR_MINOR} ${patch_dir_megous} sufix=megi
80-
run_host_command_logged cp ${patch_dir_megous}/* ${patch_dir_tmp}
81-
run_host_command_logged cat ${patch_dir_base}/series.megous ">>" ${patch_dir_base}/series.megi
78+
for tree in "${megous_trees[@]}"; do
79+
run_host_command_logged "${SRC}"/tools/mk_format_patch "${kernel_work_dir}" "master..megous/${tree}-${KERNEL_MAJOR_MINOR}" "${patch_dir_megous}" sufix=megi
80+
run_host_command_logged cp "${patch_dir_megous}"/* "${patch_dir_tmp}"
81+
run_host_command_logged cat "${patch_dir_base}/series.megous" ">>" "${patch_dir_base}/series.megi"
8282
done
8383

84-
run_host_command_logged cp ${patch_dir_tmp}/* ${patch_dir_megous}
85-
run_host_command_logged mv ${patch_dir_base}/series.megi ${patch_dir_base}/series.megous
86-
run_host_command_logged rm -rf ${patch_dir_tmp} ${patch_dir_base}/series.megi
84+
run_host_command_logged cp "${patch_dir_tmp}"/* "${patch_dir_megous}"
85+
run_host_command_logged mv "${patch_dir_base}/series.megi" "${patch_dir_base}/series.megous"
86+
run_host_command_logged rm -rf "${patch_dir_tmp}" "${patch_dir_base}/series.megi"
8787

8888
# Disable previously disabled patches
89-
grep '^-' ${PREV_KERNEL_PATCH_DIR}/series.megous | awk -F / '{print $NF}' | xargs -I {} sed -i "/\/{}/s/^/-/g" ${patch_dir_base}/series.megous
89+
grep '^-' "${PREV_KERNEL_PATCH_DIR}/series.megous" | awk -F / '{print $NF}' | xargs -I {} sed -i "/\/{}/s/^/-/g" "${patch_dir_base}/series.megous"
9090

9191
display_alert "allwinner-kernel-bump" "Generating series.conf file" "info"
92-
run_host_command_logged cat ${patch_dir_base}/series.megous ">>" ${patch_dir_base}/series.conf
93-
run_host_command_logged cat ${patch_dir_base}/series.fixes ">>" ${patch_dir_base}/series.conf
94-
run_host_command_logged cat ${patch_dir_base}/series.armbian ">>" ${patch_dir_base}/series.conf
92+
run_host_command_logged cat "${patch_dir_base}/series.megous" ">>" "${patch_dir_base}/series.conf"
93+
run_host_command_logged cat "${patch_dir_base}/series.fixes" ">>" "${patch_dir_base}/series.conf"
94+
run_host_command_logged cat "${patch_dir_base}/series.armbian" ">>" "${patch_dir_base}/series.conf"
9595
fi
9696
}

0 commit comments

Comments
 (0)