1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-11-30 21:39:43 +02:00
openwrt-xburst/include/shell.sh
mbm 9e6e9dbe21 bug #1547
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@6851 3c298f89-4303-0410-b956-a3cf2f4a3e73
2007-04-03 15:55:42 +00:00

35 lines
538 B
Bash

getvar() {
eval "echo \"\${$1}\""
}
var2file() {
local var
eval "var=\"\${$1}\""
if [ -n "$var" ]; then echo "$var" > "$2"; fi
}
isset() {
local var
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 "$@"
}