From cbe17387b84e1310a00a89ee49d7fe4e624917bf Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Mon, 29 Sep 2025 22:04:01 +0100 Subject: [PATCH] Fix error SC2068 in shell scripts Fix SC2068 (error): Double quote array expansions to avoid re-splitting elements. https://www.shellcheck.net/wiki/SC2068 --- build.sh | 2 +- eng/common/SetupNugetSources.sh | 4 ++-- eng/common/cibuild.sh | 2 +- eng/common/cross/tizen-fetch.sh | 4 ++-- eng/common/pipeline-logging-functions.sh | 2 +- eng/configure-toolset.sh | 2 +- restore.sh | 2 +- .../build/deb-package-tool/package_tool.sh | 6 +++--- .../build/deb-package-tool/scripts/debian_build_lib.sh | 4 ++-- test.sh | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/build.sh b/build.sh index 8477d5af881..b3236325088 100755 --- a/build.sh +++ b/build.sh @@ -13,4 +13,4 @@ while [[ -h $source ]]; do done scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" -"$scriptroot/eng/common/build.sh" --build --restore $@ +"$scriptroot/eng/common/build.sh" --build --restore "$@" diff --git a/eng/common/SetupNugetSources.sh b/eng/common/SetupNugetSources.sh index b97cc536379..8371578f3dc 100755 --- a/eng/common/SetupNugetSources.sh +++ b/eng/common/SetupNugetSources.sh @@ -164,7 +164,7 @@ fi DotNetVersions=('5' '6' '7' '8' '9' '10') -for DotNetVersion in ${DotNetVersions[@]} ; do +for DotNetVersion in "${DotNetVersions[@]}" ; do FeedPrefix="dotnet${DotNetVersion}"; grep -i " /dev/null if [ "$?" == "0" ]; then @@ -181,7 +181,7 @@ PackageSources+=$(grep -oh '"darc-int-[^"]*"' $ConfigFile | tr -d '"') IFS=$PrevIFS if [ "$CredToken" ]; then - for FeedName in ${PackageSources[@]} ; do + for FeedName in "${PackageSources[@]}" ; do # Check if there is no existing credential for this FeedName grep -i "<$FeedName>" $ConfigFile if [ "$?" != "0" ]; then diff --git a/eng/common/cibuild.sh b/eng/common/cibuild.sh index 66e3b0ac61c..0c5a66738da 100755 --- a/eng/common/cibuild.sh +++ b/eng/common/cibuild.sh @@ -13,4 +13,4 @@ while [[ -h $source ]]; do done scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" -. "$scriptroot/build.sh" --restore --build --test --pack --publish --ci $@ +. "$scriptroot/build.sh" --restore --build --test --pack --publish --ci "$@" diff --git a/eng/common/cross/tizen-fetch.sh b/eng/common/cross/tizen-fetch.sh index 37c3a61f1de..51cb4666139 100755 --- a/eng/common/cross/tizen-fetch.sh +++ b/eng/common/cross/tizen-fetch.sh @@ -8,7 +8,7 @@ fi Log() { if [ $VERBOSE -ge 1 ]; then - echo ${@:2} + echo "${@:2}" fi } @@ -127,7 +127,7 @@ fetch_tizen_pkgs() PACKAGE_CHECKSUM_XPATH_TPL='string(//*[local-name()="metadata"]/*[local-name()="package"][*[local-name()="name"][text()="_PKG_"]][*[local-name()="arch"][text()="_ARCH_"]]/*[local-name()="checksum"]/text())' - for pkg in ${@:2} + for pkg in "${@:2}" do Inform "Fetching... $pkg" XPATH=${PACKAGE_XPATH_TPL/_PKG_/$pkg} diff --git a/eng/common/pipeline-logging-functions.sh b/eng/common/pipeline-logging-functions.sh index 6a0b2255e91..bcc70f7acfd 100755 --- a/eng/common/pipeline-logging-functions.sh +++ b/eng/common/pipeline-logging-functions.sh @@ -36,7 +36,7 @@ function Write-PipelineTelemetryError { fi message="(NETCORE_ENGINEERING_TELEMETRY=$telemetry_category) $message" function_args+=("$message") - Write-PipelineTaskError ${function_args[@]} + Write-PipelineTaskError "${function_args[@]}" } function Write-PipelineTaskError { diff --git a/eng/configure-toolset.sh b/eng/configure-toolset.sh index 88c9010aea0..66dab68bc57 100644 --- a/eng/configure-toolset.sh +++ b/eng/configure-toolset.sh @@ -21,7 +21,7 @@ function Test-FilesUseTelemetryOutput { local file_list=`grep --files-without-match --recursive --include=*.sh "Write-PipelineTelemetryError" $scriptroot` for file in $file_list; do - for remove_file in ${require_telemetry_exclude_files[@]}; do + for remove_file in "${require_telemetry_exclude_files[@]}"; do if [[ $file =~ .*"$remove_file" ]]; then file_list=( "${file_list[@]/$file}" ) fi diff --git a/restore.sh b/restore.sh index 260efcf5ad3..b163dbd096b 100755 --- a/restore.sh +++ b/restore.sh @@ -13,4 +13,4 @@ while [[ -h $source ]]; do done scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" -"$scriptroot/eng/common/build.sh" --restore $@ \ No newline at end of file +"$scriptroot/eng/common/build.sh" --restore "$@" diff --git a/src/Microsoft.DotNet.Build.Tasks.Installers/build/deb-package-tool/package_tool.sh b/src/Microsoft.DotNet.Build.Tasks.Installers/build/deb-package-tool/package_tool.sh index 87414074d52..f308632f3da 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Installers/build/deb-package-tool/package_tool.sh +++ b/src/Microsoft.DotNet.Build.Tasks.Installers/build/deb-package-tool/package_tool.sh @@ -186,7 +186,7 @@ package_absolute_placement(){ abs_files=( $(_get_files_in_dir_tree $ABSOLUTE_PLACEMENT_DIR) ) # For each file add a a system placement - for abs_file in ${abs_files[@]} + for abs_file in "${abs_files[@]}" do parent_dir=$(dirname $abs_file) filename=$(basename $abs_file) @@ -241,7 +241,7 @@ generate_manpage_manifest(){ # Remove any existing manifest rm -f ${DEBIAN_DIR}/${PACKAGE_NAME}.manpages - for manpage in ${generated_manpages[@]} + for manpage in "${generated_manpages[@]}" do echo "${docs_rel_path}/${manpage}" >> "${DEBIAN_DIR}/${PACKAGE_NAME}.manpages" done @@ -252,7 +252,7 @@ generate_sample_manifest(){ generated_manpages=( $(_get_files_in_dir_tree $INPUT_SAMPLES_DIR) ) rm -f sample_manifest - for sample in ${samples[@]} + for sample in "${samples[@]}" do echo "$sample" >> "${DEBIAN_DIR}/${PACKAGE_NAME}.examples" done diff --git a/src/Microsoft.DotNet.Build.Tasks.Installers/build/deb-package-tool/scripts/debian_build_lib.sh b/src/Microsoft.DotNet.Build.Tasks.Installers/build/deb-package-tool/scripts/debian_build_lib.sh index 1520ffa62aa..a712e4b5591 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Installers/build/deb-package-tool/scripts/debian_build_lib.sh +++ b/src/Microsoft.DotNet.Build.Tasks.Installers/build/deb-package-tool/scripts/debian_build_lib.sh @@ -51,7 +51,7 @@ add_system_dir_placement(){ in_package_dir="${in_package_dir}/" fi - for rel_filepath in ${dir_files[@]} + for rel_filepath in "${dir_files[@]}" do local parent_path=$(dirname $rel_filepath) @@ -122,7 +122,7 @@ _copy_files_to_package(){ shift; shift; rel_filepath_list=( $@ ) - for rel_filepath in ${rel_filepath_list[@]} + for rel_filepath in "${rel_filepath_list[@]}" do local parent_dir=$(dirname $rel_filepath) local filename=$(basename $rel_filepath) diff --git a/test.sh b/test.sh index 69c2db38d30..562d1aecb90 100755 --- a/test.sh +++ b/test.sh @@ -13,4 +13,4 @@ while [[ -h $source ]]; do done scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" -"$scriptroot/eng/common/build.sh" --test $@ \ No newline at end of file +"$scriptroot/eng/common/build.sh" --test "$@"