X-Git-Url: http://git.ozo.com/?a=blobdiff_plain;f=include%2Fshell.sh;h=f6be6c526f26fb489cc660d7201bce3c3a1117b7;hb=b235d132d379565f3f3da548dabd25908717c132;hp=6ee0cf6030ac5e0a71d7be1c2438c58ee9724caf;hpb=f52d66ff00b24111f87c274d3d7085ef2e1d27b1;p=openwrt-10.03%2F.git diff --git a/include/shell.sh b/include/shell.sh index 6ee0cf603..f6be6c526 100644 --- a/include/shell.sh +++ b/include/shell.sh @@ -13,3 +13,22 @@ 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 + } + } +)} + +md5s() { + which md5sum 2>&1 >/dev/null && md5sum "$@" | awk '{print $1}' || md5 "$@" +}