scripts/functions
changeset 2340 580f427595bc
parent 2339 730e2d63296b
child 2381 0ca0f85a4b2a
     1.1 --- a/scripts/functions	Sun Mar 20 00:02:21 2011 +0100
     1.2 +++ b/scripts/functions	Tue Mar 15 23:18:37 2011 +0100
     1.3 @@ -119,12 +119,26 @@
     1.4  }
     1.5  
     1.6  # Execute an action, and log its messages
     1.7 -# Usage: [VAR=val...] CT_DoExecLog <level> <command [parameters...]>
     1.8 +# It is possible to even log local variable assignments (a-la: var=val ./cmd opts)
     1.9 +# Usage: CT_DoExecLog <level> [VAR=val...] <command> [parameters...]
    1.10  CT_DoExecLog() {
    1.11      local level="$1"
    1.12      shift
    1.13 -    CT_DoLog DEBUG "==> Executing: '${*}'"
    1.14 +    (
    1.15 +    for i in "$@"; do
    1.16 +        tmp_log+="'${i}' "
    1.17 +    done
    1.18 +    while true; do
    1.19 +        case "${1}" in
    1.20 +            *=*)    eval export "'${1}'"; shift;;
    1.21 +            *)      break;;
    1.22 +        esac
    1.23 +    done
    1.24 +    CT_DoLog DEBUG "==> Executing: ${tmp_log}"
    1.25      "${@}" 2>&1 |CT_DoLog "${level}"
    1.26 +    )
    1.27 +    # Catch failure of the sub-shell
    1.28 +    [ $? -eq 0 ]
    1.29  }
    1.30  
    1.31  # Tail message to be logged whatever happens