2014-10-27 00:18:24 +08:00
|
|
|
getvar() {
|
|
|
|
eval "echo \"\${$1}\""
|
|
|
|
}
|
|
|
|
|
2006-10-10 23:30:50 +08:00
|
|
|
var2file() {
|
|
|
|
local var
|
|
|
|
eval "var=\"\${$1}\""
|
|
|
|
if [ -n "$var" ]; then echo "$var" > "$2"; fi
|
|
|
|
}
|
|
|
|
|
|
|
|
isset() {
|
|
|
|
local var
|
|
|
|
eval "var=\"\${$1}\""
|
|
|
|
[ -n "$var" ]
|
|
|
|
}
|
2006-11-27 12:25:34 +08:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)}
|
2007-03-24 03:13:08 +08:00
|
|
|
|
|
|
|
md5s() {
|
2008-09-02 18:57:51 +08:00
|
|
|
cat "$@" | (
|
|
|
|
md5sum 2>/dev/null ||
|
2015-03-29 15:29:18 +08:00
|
|
|
md5
|
2008-09-02 18:57:51 +08:00
|
|
|
) | awk '{print $1}'
|
2007-03-24 03:13:08 +08:00
|
|
|
}
|