From: Ben Crocker <bcrocker@xxxxxxxxxx> In this commit, fix SC2086 warnings flagged by the shellcheck tool: https://www.shellcheck.net/wiki/SC2086 "Double quote to prevent globbing and word splitting." This also helps tools like dirname to handle a zero-length argument rationally. Signed-off-by: Ben Crocker <bcrocker@xxxxxxxxxx> --- redhat/configs/generate_all_configs.sh | 4 +-- redhat/configs/process_configs.sh | 50 +++++++++++++------------- redhat/parallel_xz.sh | 2 +- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/redhat/configs/generate_all_configs.sh b/redhat/configs/generate_all_configs.sh index 14f0f3a24de5..c5899e3a582d 100755 --- a/redhat/configs/generate_all_configs.sh +++ b/redhat/configs/generate_all_configs.sh @@ -9,11 +9,11 @@ PRIMARY=$1 DEBUGBUILDSENABLED=$2 -if [ -z $2 ]; then +if [ -z "$2" ]; then exit 1 fi -if [ $PRIMARY == "fedora" ]; then +if [ "$PRIMARY" == "fedora" ]; then SECONDARY=rhel else SECONDARY=fedora diff --git a/redhat/configs/process_configs.sh b/redhat/configs/process_configs.sh index 14773fef2410..75ec4ca77c4a 100755 --- a/redhat/configs/process_configs.sh +++ b/redhat/configs/process_configs.sh @@ -30,11 +30,11 @@ switch_to_toplevel() path="$(pwd)" while test -n "$path" do - test -e $path/MAINTAINERS && \ - test -d $path/drivers && \ + test -e "$path"/MAINTAINERS && \ + test -d "$path"/drivers && \ break - path="$(dirname $path)" + path="$(dirname "$path")" done test -n "$path" || die "Can't find toplevel" @@ -65,7 +65,7 @@ checkoptions() print "Found "a[1]"="a[2]" after generation, had " a[1]"="configs[a[1]]" in Source tree"; } } - ' $1 $2 > .mismatches + ' "$1" "$2" > .mismatches if test -s .mismatches then @@ -84,7 +84,7 @@ parsenewconfigs() # and puts it into CONFIG_FOO files. Using the output of # listnewconfig is much easier to ensure we get the default # output. - /usr/bin/awk -v BASE=$tmpdir ' + /usr/bin/awk -v BASE="$tmpdir" ' /is not set/ { split ($0, a, "#"); split(a[2], b); @@ -109,7 +109,7 @@ parsenewconfigs() # each CONFIG_FOO file. Because of how awk works # there's a lot of moving files around and catting to # get what we need. - /usr/bin/awk -v BASE=$tmpdir ' + /usr/bin/awk -v BASE="$tmpdir" ' BEGIN { inpatch=0; outfile="none"; symbol="none"; } @@ -141,15 +141,15 @@ parsenewconfigs() ' .helpnewconfig - pushd $tmpdir &> /dev/null + pushd "$tmpdir" &> /dev/null rm fake_* popd &> /dev/null - for f in `ls $tmpdir`; do - [[ -e "$tmpdir/$f" ]] || break - cp $tmpdir/$f $SCRIPT_DIR/pending"$FLAVOR"/generic/ + for f in $(ls "$tmpdir"); do + [[ -e "$tmpdir"/"$f" ]] || break + cp "$tmpdir"/"$f" "$SCRIPT_DIR"/pending"$FLAVOR"/generic/ done - rm -rf $tmpdir + rm -rf "$tmpdir" } function commit_new_configs() @@ -159,10 +159,10 @@ function commit_new_configs() for cfg in $SCRIPT_DIR/${PACKAGE_NAME}${KVERREL}${SUBARCH}*.config do - arch=$(head -1 $cfg | cut -b 3-) + arch=$(head -1 "$cfg" | cut -b 3-) cfgtmp="${cfg}.tmp" cfgorig="${cfg}.orig" - cat $cfg > $cfgorig + cat "$cfg" > "$cfgorig" if [ "$arch" = "EMPTY" ] then @@ -171,18 +171,18 @@ function commit_new_configs() fi echo -n "Checking for new configs in $cfg ... " - make ARCH=$arch KCONFIG_CONFIG=$cfgorig listnewconfig >& .listnewconfig + make ARCH="$arch" KCONFIG_CONFIG="$cfgorig" listnewconfig >& .listnewconfig grep -E 'CONFIG_' .listnewconfig > .newoptions if test -s .newoptions then - make ARCH=$arch KCONFIG_CONFIG=$cfgorig helpnewconfig >& .helpnewconfig + make ARCH="$arch" KCONFIG_CONFIG="$cfgorig" helpnewconfig >& .helpnewconfig parsenewconfigs fi rm .newoptions echo "done" done - git add $SCRIPT_DIR/pending"$FLAVOR" + git add "$SCRIPT_DIR"/pending"$FLAVOR" git commit -m "[redhat] AUTOMATIC: New configs" } @@ -191,12 +191,12 @@ function process_configs() # assume we are in $source_tree/configs, need to get to top level pushd $(switch_to_toplevel) &>/dev/null - for cfg in $SCRIPT_DIR/${PACKAGE_NAME}${KVERREL}${SUBARCH}*.config + for cfg in "$SCRIPT_DIR"/"${PACKAGE_NAME}${KVERREL}${SUBARCH}"*.config do - arch=$(head -1 $cfg | cut -b 3-) + arch=$(head -1 "$cfg" | cut -b 3-) cfgtmp="${cfg}.tmp" cfgorig="${cfg}.orig" - cat $cfg > $cfgorig + cat "$cfg" > "$cfgorig" if [ "$arch" = "EMPTY" ] then @@ -205,7 +205,7 @@ function process_configs() fi echo -n "Processing $cfg ... " - make ARCH=$arch KCONFIG_CONFIG=$cfgorig listnewconfig >& .listnewconfig + make ARCH="$arch" KCONFIG_CONFIG="$cfgorig" listnewconfig >& .listnewconfig grep -E 'CONFIG_' .listnewconfig > .newoptions if test -n "$NEWOPTIONS" && test -s .newoptions then @@ -230,21 +230,21 @@ function process_configs() rm .listnewconfig - make ARCH=$arch KCONFIG_CONFIG=$cfgorig olddefconfig > /dev/null || exit 1 + make ARCH="$arch" KCONFIG_CONFIG="$cfgorig" olddefconfig > /dev/null || exit 1 echo "# $arch" > ${cfgtmp} cat "${cfgorig}" >> ${cfgtmp} if test -n "$CHECKOPTIONS" then - checkoptions $cfg $cfgtmp + checkoptions "$cfg" "$cfgtmp" fi # if test run, don't overwrite original if test -n "$TESTRUN" then - rm ${cfgtmp} + rm "${cfgtmp}" else - mv ${cfgtmp} ${cfg} + mv "${cfgtmp}" "${cfg}" fi - rm ${cfgorig} + rm "${cfgorig}" echo "done" done rm "$SCRIPT_DIR"/*.config*.old diff --git a/redhat/parallel_xz.sh b/redhat/parallel_xz.sh index bc08a548dbee..f1b6cdd1594d 100755 --- a/redhat/parallel_xz.sh +++ b/redhat/parallel_xz.sh @@ -23,4 +23,4 @@ test "$procgroup" = 1 && exec xargs -r xz # xz has some startup cost. If files are really small, # this cost might be significant. To combat this, # process several files (in sequence) by each xz process via -n 16: -exec xargs -r -n 16 -P $procgroup xz +exec xargs -r -n 16 -P "$procgroup" xz -- GitLab _______________________________________________ kernel mailing list -- kernel@xxxxxxxxxxxxxxxxxxxxxxx To unsubscribe send an email to kernel-leave@xxxxxxxxxxxxxxxxxxxxxxx Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/kernel@xxxxxxxxxxxxxxxxxxxxxxx