]> git.ozlabs.org Git - next-scripts/commitdiff
start of shellcheck fixes
authorStephen Rothwell <sfr@canb.auug.org.au>
Tue, 9 Feb 2016 22:25:33 +0000 (09:25 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 9 Feb 2016 22:25:33 +0000 (09:25 +1100)
build_msg
build_warn
check_left
common.sh
do_build
do_merge

index 2e7884bdd53a82cfe1a568b7c4002362cf496de6..5ba2bbb83f9ad6b73c542e499d1c7f7b60a2d5a2 100755 (executable)
--- a/build_msg
+++ b/build_msg
@@ -2,7 +2,8 @@
 
 subject="build failure after merge of the BRANCH tree"
 
-$(dirname $0)/message_helper "$@" "$subject" <<EOF
+tools_dir=$(dirname "$0")
+"$tools_dir"/message_helper "$@" "$subject" <<EOF
 After merging the BRANCH tree, today's linux-next build (KCONFIG_NAME) failed like this:
 
 
index e4c4ac582be4808f66583f52ed274d5648f67e15..67a430b5cebe3867d8edb5739ec7e635205a454e 100755 (executable)
@@ -2,7 +2,8 @@
 
 subject="build warning after merge of the BRANCH tree"
 
-$(dirname $0)/message_helper "$@" "$subject" <<EOF
+tools_dir=$(dirname "$0")
+"$tools_dir"/message_helper "$@" "$subject" <<EOF
 After merging the BRANCH tree, today's linux-next build (KCONFIG_NAME) produced this warning:
 
 
index bcdf81e75ed42dc44d09042792c6d287eb315e09..27c8ad3394f84b862cd8ffec367e999bdbd1ca48 100755 (executable)
@@ -2,28 +2,23 @@
 
 LOG_FILE="../left_over.log"
 
-cp /dev/null $LOG_FILE
-
-log()
-{
-       echo "$@" | tee -a $LOG_FILE
-}
+cp /dev/null "$LOG_FILE"
 
 heads=$(grep -v '^#' ../etc/control | awk -F ' ' '$2=="quilt" { printf("quilt/%s ", $3); } $2=="git" { printf("%s/%s ", $3, $5); }')
 
 for h in $heads; do
-       echo $h
-       mb=$(git merge-base origin/master $h)
-       rh=$(git rev-parse $h)
+       echo "$h"
+       mb=$(git merge-base origin/master "$h")
+       rh=$(git rev-parse "$h")
        [ "$mb" = "$rh" ] &&
                continue
 
-       c=$(git rev-list --pretty='format:%m%H' --no-merges --left-right --cherry-pick origin/master...$h | sed -n 's/^>//p')
+       c=$(git rev-list --pretty='format:%m%H' --no-merges --left-right --cherry-pick origin/master..."$h" | sed -n 's/^>//p')
        [ -z "$c" ] &&
                continue
 
-       log $h "$(echo $c | wc -w)" | tee -a $LOG_FILE
-       git shortlog --no-walk $c 2>&1 | tee -a $LOG_FILE
+       echo "$h" $(echo "$c" | wc -w) | tee -a "$LOG_FILE"
+       git shortlog --no-walk "$c" 2>&1 | tee -a "$LOG_FILE"
 
 #      gitk stable..$h
 
index cb720a87adcfba4d6ec7e820aae6af3cb1217127..cd683a58f98de8bfd470a053b5f1cacac106eb0f 100644 (file)
--- a/common.sh
+++ b/common.sh
@@ -6,7 +6,7 @@
 [ "$_next_common_included" ] && return 0
 _next_common_included=1
 
-bin_dir="$(dirname $0)"
+bin_dir=$(dirname "$0")
 
 LOG_FILE="../merge.log"
 SHA1_FILE="../SHA1s"
index 4a5e2c385786b822bf7ced398b3787d2e75a22a6..a49f1b4cb89afc7380499b8f6ea8c12f842aa66d 100755 (executable)
--- a/do_build
+++ b/do_build
@@ -1,6 +1,7 @@
 #!/bin/sh
 
-. "$(dirname $0)/common.sh"
+tools_dir=$(dirname "$0")
+. "$tools_dir/common.sh"
 
 set -e
 
@@ -32,27 +33,27 @@ $cmd <<-EOF
        e=\$d.except
        echo CONFIG_BUILD_DOCSRC=n >\$e || exit 1
        echo CONFIG_MODULES=y >>\$e || exit 1
-       KCONFIG_ALLCONFIG=\$e cross -n -N -a x86_64 -c $gcc_version O=\$d allmodconfig || exit 1
+       KCONFIG_ALLCONFIG=\$e cross -n -N -a x86_64 -c "$gcc_version" O=\$d allmodconfig || exit 1
        echo "Forking x86 build ..."
-       /usr/bin/time cross -n -N -a x86_64 -c $gcc_version O=\$d -j$j_factor -s > \$log_x86 2>&1 &
+       /usr/bin/time cross -n -N -a x86_64 -c "$gcc_version" O=\$d -j"$j_factor" -s > \$log_x86 2>&1 &
        x86_64_pid=\$!
 
        echo Building: powerpc ppc64_defconfig
        d="$bparent/powerpc_ppc64_defconfig"
        [ -d \$d ] || mkdir \$d || exit 1
        log_ppc=\$d.log
-       cross -n -N -a powerpc64 -k powerpc -c $gcc_ppc_version O=\$d ppc64_defconfig || exit 1
+       cross -n -N -a powerpc64 -k powerpc -c "$gcc_ppc_version" O=\$d ppc64_defconfig || exit 1
        echo "Forking powerpc build ..."
-       /usr/bin/time cross -n -N -a powerpc64 -k powerpc -c $gcc_ppc_version O=\$d -j$j_factor -s > \$log_ppc 2>&1 &
+       /usr/bin/time cross -n -N -a powerpc64 -k powerpc -c "$gcc_ppc_version" O=\$d -j"$j_factor" -s > \$log_ppc 2>&1 &
        ppc64_pid=\$!
 
        echo Building: arm multi_v7_defconfig
        d="$bparent/arm_multi_v7_defconfig"
        [ -d \$d ] || mkdir \$d || exit 1
        log_arm=\$d.log
-       cross -n -N -a arm -c $gcc_version O=\$d multi_v7_defconfig || exit 1
+       cross -n -N -a arm -c "$gcc_version" O=\$d multi_v7_defconfig || exit 1
        echo "Forking arm build ..."
-       /usr/bin/time cross -n -N -a arm -c $gcc_version O=\$d -j$j_factor -s > \$log_arm 2>&1 &
+       /usr/bin/time cross -n -N -a arm -c "$gcc_version" O=\$d -j"$j_factor" -s > \$log_arm 2>&1 &
        arm_pid=\$!
 
        echo Building: perf
@@ -60,7 +61,7 @@ $cmd <<-EOF
        [ -d \$d ] || mkdir \$d || exit 1
        log_perf=\$d.log
        echo "Forking perf build ..."
-       /usr/bin/time make -s -C tools/perf JOBS=$j_factor O=\$d > \$log_perf 2>&1 &
+       /usr/bin/time make -s -C tools/perf JOBS="$j_factor" O=\$d > \$log_perf 2>&1 &
        perf_pid=\$!
 
        wait \$perf_pid
index b9ed8f968c18696079e24a4c9b392a5946747e3d..7b13a50edda2ce45e9f706f18bd6cac0d308f016 100755 (executable)
--- a/do_merge
+++ b/do_merge
@@ -17,32 +17,33 @@ start_from=""
        shift
 }
 
-. "$(dirname $0)/common.sh"
+tool_dir=$(dirname "$0")
+. "$tool_dir/common.sh"
 
 log()
 {
-       echo "$@" | tee -a $LOG_FILE
+       echo "$@" | tee -a "$LOG_FILE"
 }
 
 execute()
 {
-       log "$" $@
-       $@ 2>&1 | tee -a $LOG_FILE
-       return ${PIPESTATUS[0]}
+       log "$" "$@"
+       "$@" 2>&1 | tee -a "$LOG_FILE"
+       return "${PIPESTATUS[0]}"
 }
 
 do_rebase()
 {
        rbase=${1#*/}
-       rbase=${rbase%%:*}
-       rtop=${1#*:}
-       rbid=$(git rev-parse $2/$rbase)
-       rtid=$(git rev-parse $2/$rtop)
+       rbase="$2/${rbase%%:*}"
+       rtop="$2/${1#*:}"
+       rbid=$(git rev-parse "$rbase")
+       rtid=$(git rev-parse "$rtop")
        [ "$rbid" = "$rtid" ] && {
                echo Empty tree
                return
        }
-       [ "$(git rev-list HEAD..$2/$rtop)" ] || {
+       [ "$(git rev-list HEAD..$rtop)" ] || {
                echo Already merged
                return
        }
@@ -52,27 +53,27 @@ do_rebase()
        }
        log '$' cd ../rebase-tmp
        cd ../rebase-tmp
-       execute git fetch --no-tags ../next refs/remotes/$2/$rtop:$2/$rtop || {
+       execute git fetch --no-tags ../next "refs/remotes/$rtop:$rtop" || {
                echo Fetch of top failed 1>&2
                bash -i || exit
        }
-       execute git fetch --no-tags ../next refs/remotes/$2/$rbase:$2/$rbase || {
+       execute git fetch --no-tags ../next "refs/remotes/$rbase:$rbase" || {
                echo Fetch of base failed 1>&2
                bash -i || exit
        }
-       execute git checkout $2/$rtop || {
+       execute git checkout "$rtop" || {
                echo Checkout of top failed 1>&2
                bash -i || exit
        }
-       execute git rebase --onto master $2/$rbase || {
+       execute git rebase --onto master "$rbase" || {
                echo Rebase failed 1>&2
                bash -i || exit
        }
        log '$' cd ../next
        cd ../next
-       execute git pull -f ../rebase-tmp $2/$rtop || {
+       execute git pull -f ../rebase-tmp "$rtop" || {
                echo Pull failed 1>&2
-               echo $h >>../merge.debug
+               echo "$h" >>../merge.debug
                git diff >>../merge.debug 2>&1
                git diff 2>&1 | egrep -q '<<<<<|^\*' && {
                        bash -i || exit
@@ -82,15 +83,15 @@ do_rebase()
 }
 
 [ -n "$start_from" ] || {
-       cp /dev/null $LOG_FILE
+       cp /dev/null "$LOG_FILE"
        execute date -R
        execute git checkout master
        execute git reset --hard stable
-       printf 'Name\t\tSHA1\n----\t\t----\n' > $SHA1_FILE
+       printf 'Name\t\tSHA1\n----\t\t----\n' > "$SHA1_FILE"
 
 }
 
-heads=$(grep -v '^#' $CTRL_FILE | awk -F '\t' '$2=="quilt" || $2=="git" { printf("%s/%s ", $3, $5); }')
+heads=$(grep -v '^#' "$CTRL_FILE" | awk -F '\t' '$2=="quilt" || $2=="git" { printf("%s/%s ", $3, $5); }')
 
 need_build=false
 
@@ -105,7 +106,7 @@ for h in $heads; do
                fi
        }
 
-       hlog=$(git log -1 --oneline ${h/\/*://}) 2>/dev/null
+       hlog=$(git log -1 --oneline "${h/\/*://}") 2>/dev/null
        old_head=$(git rev-parse HEAD)
        [ -f "../pre-merge/$tree" ] && {
                for p in $(cat "../pre-merge/$tree"); do
@@ -115,15 +116,15 @@ for h in $heads; do
                        }
                done
        }
-       log Merging $h "($hlog)"
+       log Merging "$h" "($hlog)"
        case "$h" in
        *:*)
-               do_rebase $h $tree
+               do_rebase "$h" "$tree"
                ;;
        *)
-               execute git merge $h || {
+               execute git merge "$h" || {
                        echo Merge failed 1>&2
-                       echo $h >>../merge.debug
+                       echo "$h" >>../merge.debug
                        git diff >>../merge.debug 2>&1
                        um_files=$(git diff 2>&1 | sed -n 's/^\* Unmerged path //p')
                        [ "$um_files" ] && [ -f "../merge-files/$tree" ] && {