2006-10-10 15:30:50 +00:00
|
|
|
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" ]
|
|
|
|
}
|
2006-11-27 04:25:34 +00: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-23 19:13:08 +00:00
|
|
|
|
|
|
|
md5s() {
|
2007-04-03 15:55:42 +00:00
|
|
|
which md5sum 2>&1 >/dev/null && md5sum "$@" | awk '{print $1}' || md5 "$@"
|
2007-03-23 19:13:08 +00:00
|
|
|
}
|