From 7f4dd2921a6022786fbf5ac7a2ea3efd2f4c0ad9 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Fri, 25 Apr 2014 03:44:15 -0700 Subject: [PATCH] Revert "shlib.sh: Add new bang_eval function" This reverts commit ef3b12193f2102fca88abd9530f3dfb8ffc14616. The implementation of bang_eval is unnecessarily complex. Revert the prior implementation in prelude to a much simpler implementation. --- shlib.sh | 79 ++++++++++++++++++---------------------------------------------- 1 file changed, 22 insertions(+), 57 deletions(-) diff --git a/shlib.sh b/shlib.sh index 2cfc180..e7cf9aa 100644 --- a/shlib.sh +++ b/shlib.sh @@ -85,35 +85,6 @@ mail() { } | _sendmail "$@" } -# Supports both the bang CMD... and bang_eval CMD... functions -# Called when the command fails -# Should only be called from bang and bang_eval functions -bang_err() { - if ! [ -e .banged ]; then - bangmailok=true - ! [ -f HEAD -a -f config -a -d objects ] || - bangmailok="$(GIT_DIR=. git config --bool gitweb.statusupdates 2>/dev/null || echo true)" - bangaddrs='' - [ "$bangmailok" = "false" -o -z "$mail" ] || bangaddrs="$mail" - [ -z "$cfg_admincc" -o "$cfg_admincc" = "0" -o -z "$cfg_admin" ] || - if [ -z "$bangaddrs" ]; then bangaddrs="$cfg_admin"; else bangaddrs="$bangaddrs,$cfg_admin"; fi - [ -z "$bangaddrs" ] || - { - echo "$* failed with error code $errcode" - echo "" - [ ! -n "$bang_once" ] || echo "you will not receive any more notifications until recovery" - echo "this status message may be disabled on the project admin page" - echo "" - echo "Log follows:" - echo "" - cat "$bang_log" - } | mail -s "[$cfg_name] $proj $bang_action failed" "$bangaddrs" - fi - touch .banged - bang_trap - exit 1 -} - # bang CMD... will execute the command with well-defined failure mode; # set bang_action to string of the failed action ('clone', 'update', ...); # pre-set bang_once=1 to make sure jobs banging on a repo repeatedly will @@ -142,35 +113,29 @@ bang() { errcode="$?" fi fi - bang_err "$@" -} - -# bang_eval CMD... will evaluate the command with well-defined failure mode; -# Identical to bang CMD... except the command is eval'd instead of executed. -bang_eval() { - if [ -n "$show_progress" ]; then - exec 3>&1 - errcode= - read -r errcode <<-EOT || : - $( - exec 4>&3 3>&1 1>&4 4>&- - { eval "$*" 3>&- || echo $? >&3; } 2>&1 | tee -a "$bang_log" - ) - EOT - exec 3>&- - if [ -z "$errcode" ]; then - # All right. Cool. - return; - fi - else - if eval "$*" >>"$bang_log" 2>&1; then - # All right. Cool. - return; - else - errcode="$?" - fi + if ! [ -e .banged ]; then + bangmailok=true + ! [ -f HEAD -a -f config -a -d objects ] || + bangmailok="$(GIT_DIR=. git config --bool gitweb.statusupdates 2>/dev/null || echo true)" + bangaddrs='' + [ "$bangmailok" = "false" -o -z "$mail" ] || bangaddrs="$mail" + [ -z "$cfg_admincc" -o "$cfg_admincc" = "0" -o -z "$cfg_admin" ] || + if [ -z "$bangaddrs" ]; then bangaddrs="$cfg_admin"; else bangaddrs="$bangaddrs,$cfg_admin"; fi + [ -z "$bangaddrs" ] || + { + echo "$* failed with error code $errcode" + echo "" + [ ! -n "$bang_once" ] || echo "you will not receive any more notifications until recovery" + echo "this status message may be disabled on the project admin page" + echo "" + echo "Log follows:" + echo "" + cat "$bang_log" + } | mail -s "[$cfg_name] $proj $bang_action failed" "$bangaddrs" fi - bang_err "$@" + touch .banged + bang_trap + exit 1 } # Default bang settings: -- 2.11.4.GIT