X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;f=include%2Fshell.sh;h=1e60692b97fffcc1864146345da6b761cbe6c3f7;hb=21737380f6897440b3c6bb58a3fe7c18f668b81d;hp=6ee0cf6030ac5e0a71d7be1c2438c58ee9724caf;hpb=39ed9eab85c390e575242b9d170f290272b6f582;p=openwrt%2Fsvn-archive%2Farchive.git diff --git a/include/shell.sh b/include/shell.sh index 6ee0cf6030..1e60692b97 100644 --- a/include/shell.sh +++ b/include/shell.sh @@ -13,3 +13,18 @@ isset() { eval "var=\"\${$1}\"" [ -n "$var" ] } + +trapret() {( + local retvals="$1"; shift + local cmd="$1"; shift + for retval in $(echo $retvals); do + local trap_$retval=1 + done + "$cmd" "$@" || { + local retval="$?" + eval "trapped=\${trap_$retval}" + [ -n "$trapped" ] || { + return $retval + } + } +)}