diff options
author | Yann E. MORIN" <yann.morin.1998@anciens.enib.fr> | 2011-03-15 23:18:37 +0100 |
---|---|---|
committer | Yann E. MORIN" <yann.morin.1998@anciens.enib.fr> | 2011-03-15 23:18:37 +0100 |
commit | 807daf12d0a0f36c6b8df4c48327efa0ac899484 (patch) | |
tree | 468a4ad1e4ce7914df31a35e84fbb97463f42b2e /scripts/functions | |
parent | 7bfa4139adfb9175ade8787a425a3baedee7a748 (diff) | |
download | crosstool-ng-807daf12d0a0f36c6b8df4c48327efa0ac899484.tar.gz crosstool-ng-807daf12d0a0f36c6b8df4c48327efa0ac899484.tar.bz2 crosstool-ng-807daf12d0a0f36c6b8df4c48327efa0ac899484.zip |
scripts: allow logging of commands with variables
In a lot of places, we need to call some commands with specific
variable settings, a-la:
var1=val1 var2=val2 /foo/bar/buz opt1 opt2
Unfortunately, we currently can not log the variable settings.
Enhance CT_DoExecLog with a crude heuristic that works pretty well
and that can also log setting variables.
Reported-by: ANDY KENNEDY <ANDY.KENNEDY@adtran.com>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Diffstat (limited to 'scripts/functions')
-rw-r--r-- | scripts/functions | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/scripts/functions b/scripts/functions index 38495949..2bf57678 100644 --- a/scripts/functions +++ b/scripts/functions @@ -119,12 +119,26 @@ CT_DoLog() { } # Execute an action, and log its messages -# Usage: [VAR=val...] CT_DoExecLog <level> <command [parameters...]> +# It is possible to even log local variable assignments (a-la: var=val ./cmd opts) +# Usage: CT_DoExecLog <level> [VAR=val...] <command> [parameters...] CT_DoExecLog() { local level="$1" shift - CT_DoLog DEBUG "==> Executing: '${*}'" + ( + for i in "$@"; do + tmp_log+="'${i}' " + done + while true; do + case "${1}" in + *=*) eval export "'${1}'"; shift;; + *) break;; + esac + done + CT_DoLog DEBUG "==> Executing: ${tmp_log}" "${@}" 2>&1 |CT_DoLog "${level}" + ) + # Catch failure of the sub-shell + [ $? -eq 0 ] } # Tail message to be logged whatever happens |