From: Stephen Rothwell Date: Wed, 4 Jun 2008 01:38:35 +0000 (+1000) Subject: Consolidate error recovery into "execute" X-Git-Url: https://git.ozlabs.org/?a=commitdiff_plain;h=61ff53ec669b5b5695d21683d0a55ca728a843dd;p=next-scripts Consolidate error recovery into "execute" --- diff --git a/update_trees b/update_trees index eef1286..7e5525c 100755 --- a/update_trees +++ b/update_trees @@ -1,7 +1,5 @@ #!/bin/bash -set -o pipefail - cp /dev/null ../quilt-import.log log() @@ -13,6 +11,11 @@ execute() { log "$" $@ "$@" 2>&1 | tee -a ../quilt-import.log + [ ${PIPESTATUS[0]} -eq 0 ] || sh -i || { + [ -f "$sfile.orig" ] && + mv -f "$sfile.orig" "$sfile" + exit 1 + } } quilters=$(grep -v '^#' ../real_control | awk -F ' ' '$2=="quilt" { print $3; }') @@ -54,11 +57,7 @@ for name in $quilters; do } git show-ref --quiet --verify "refs/heads/quilt/$name" || - execute git branch "quilt/$name" "$rbase" || sh -i || { - [ -f "$sfile.orig" ] && - mv -f "$sfile.orig" "$sfile" - exit 1 - } + execute git branch "quilt/$name" "$rbase" mv -f "$sfile" "$sfile.tmp" sed -e '/^[ ]*$/d' -e '^[ ]*#/d' <"$sfile.tmp" >"$sfile" @@ -70,23 +69,11 @@ for name in $quilters; do continue } - execute git checkout "quilt/$name" || sh -i || { - [ -f "$sfile.orig" ] && - mv -f "$sfile.orig" "$sfile" - exit 1 - } - execute git reset --hard "$rbase" || sh -i || { - [ -f "$sfile.orig" ] && - mv -f "$sfile.orig" "$sfile" - exit 1 - } + execute git checkout "quilt/$name" + execute git reset --hard "$rbase" author=$(grep -v '^#' ../real_control | awk -F ' ' '$3=="'"$name"'" { printf("%s", $1); }' | sed 's/,.*$//') - execute git quiltimport --author "$author" --patches "../quilt/$name" || sh -i || { - [ -f "$sfile.orig" ] && - mv -f "$sfile.orig" "$sfile" - exit 1 - } + execute git quiltimport --author "$author" --patches "../quilt/$name" [ -f "$sfile.orig" ] && mv -f "$sfile.orig" "$sfile"