1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-11-01 23:42:49 +02:00
openwrt-xburst/include/shell.sh
nbd fef278a548 clean up md5s() shell function
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@12493 3c298f89-4303-0410-b956-a3cf2f4a3e73
2008-09-02 10:57:51 +00:00

38 lines
529 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() {
cat "$@" | (
md5sum 2>/dev/null ||
md5
) | awk '{print $1}'
}