From 8bad28ceca25eecbf7c82c22166b1042a298d74f Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Wed, 10 Feb 2016 09:25:33 +1100 Subject: [PATCH] start of shellcheck fixes --- build_msg | 3 ++- build_warn | 3 ++- check_left | 19 +++++++------------ common.sh | 2 +- do_build | 17 +++++++++-------- do_merge | 49 +++++++++++++++++++++++++------------------------ 6 files changed, 46 insertions(+), 47 deletions(-) diff --git a/build_msg b/build_msg index 2e7884b..5ba2bbb 100755 --- a/build_msg +++ b/build_msg @@ -2,7 +2,8 @@ subject="build failure after merge of the BRANCH tree" -$(dirname $0)/message_helper "$@" "$subject" <//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 diff --git a/common.sh b/common.sh index cb720a8..cd683a5 100644 --- 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" diff --git a/do_build b/do_build index 4a5e2c3..a49f1b4 100755 --- 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 diff --git a/do_merge b/do_merge index b9ed8f9..7b13a50 100755 --- 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" ] && { -- 2.39.2