implémentation initiale evalx()

This commit is contained in:
Jephte CLAIN 2014-09-05 07:28:09 +04:00
parent 4a2581cd2e
commit b0dd82e993
1 changed files with 41 additions and 0 deletions

View File

@ -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