From bd101f50fed9ec75d4d3044c503e79863b060154 Mon Sep 17 00:00:00 2001 From: "Matthias J. Kannwischer" Date: Wed, 21 Oct 2026 19:34:33 +0800 Subject: [PATCH] format: Pass file names to sh -c as arguments Substituting file names into the sh -c script text executed shell syntax contained in them. - Resolves #1213. Signed-off-by: Matthias J. Kannwischer --- scripts/format | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/format b/scripts/format index 3cf55ca5dd..2cec0273c1 100755 --- a/scripts/format +++ b/scripts/format @@ -62,19 +62,19 @@ nproc=$(getconf _NPROCESSORS_ONLN || echo 1) git ls-files -- ":/*.c" ":/*.h" | xargs -P "$nproc" -I {} sh -c ' # Ignore symlinks - if [[ ! -L {} ]]; then - clang-format -i {} - fi' + if [[ ! -L "$1" ]]; then + clang-format -i "$1" + fi' _ {} info "Expanding tabs" expand-tabs() { git ls-files -- ":/" ":/!:Makefile" ":/!:**/Makefile" ":/!:**/Makefile.*" ":/!:Makefile.*" ":/!:*.mk" ":/!:*.patch" ":/!:nix/valgrind/*.txt" | xargs -P "$nproc" -I {} sh -c ' - if [ ! -L {} ] && grep -Pq '"'"'\t'"'"' "{}"; then + if [ ! -L "$1" ] && grep -Pq '"'"'\t'"'"' "$1"; then tmp=$(mktemp) - expand -t 4 "{}" > "$tmp" && mv "$tmp" "{}" - echo "{}" - fi' + expand -t 4 "$1" > "$tmp" && mv "$tmp" "$1" + echo "$1" + fi' _ {} } expand-tabs @@ -83,9 +83,9 @@ check-eol() { git ls-files -- ":/" ":/!:*.png" | xargs -P "$nproc" -I {} sh -c ' # Ignore symlinks - if [[ ! -L {} && $(tail -c1 "{}" | wc -l) == 0 ]]; then - echo "" >>"{}" - echo "{}" - fi' + if [[ ! -L "$1" && $(tail -c1 "$1" | wc -l) == 0 ]]; then + echo "" >>"$1" + echo "$1" + fi' _ {} } check-eol