X-Git-Url: http://git.ozo.com/?p=openwrt-10.03%2F.git;a=blobdiff_plain;f=include%2Fshell.sh;h=1e60692b97fffcc1864146345da6b761cbe6c3f7;hp=6ee0cf6030ac5e0a71d7be1c2438c58ee9724caf;hb=97c8cb1b64a660538b7ef6cf5a9b98f904a8bccc;hpb=bfcaec7ec83ccd7ce75cb001ef899de22745aa05 diff --git a/include/shell.sh b/include/shell.sh index 6ee0cf603..1e60692b9 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 + } + } +)}