diff --git a/lib/ulib/base b/lib/ulib/base index 3513247..c8c9693 100644 --- a/lib/ulib/base +++ b/lib/ulib/base @@ -155,6 +155,47 @@ function _seta() { local __s_array="$1"; shift eval "$__s_array=($("$@" | qlines))" } +function evalx() { +# évaluer ... + local val arg r=0 + local -a cmd + + local first=1 + while [ $# -gt 0 ]; do + cmd=() + while [ $# -gt 0 ]; do + arg="$1"; shift + [ "$arg" == // ] && break + if [ "${arg%//}" != "$arg" ]; then + local tmp="${arg%//}" + if [ -z "${tmp//\\/}" ]; then + arg="${arg#\\}" + cmd=("${cmd[@]}" "$arg") + continue + fi + fi + cmd=("${cmd[@]}" "$arg") + done + + if [ -n "$first" ]; then + val="$("${cmd[@]}")" || r=$? + else + val="$("${cmd[@]}" "$val")" || r=$? + fi + first= + done + [ -n "$val" ] && echo "$val" + return $r +} +function evalp() { +# évaluer ... + : +} +function testx() { +# tester ... + : +} + function e2of() { # lancer la commande $@ en redirigeant la sortie d'erreur sur la sortie standard "$@" 2>&1