mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-23 15:32:33 +00:00
43f485f334
Signed-off-by: Felix Fietkau <nbd@openwrt.org> SVN-Revision: 43020
34 lines
491 B
Bash
34 lines
491 B
Bash
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}'
|
|
}
|