ar7: backport small fixes from linux-mips
[openwrt.git] / include / shell.sh
1 getvar() {
2 eval "echo \"\${$1}\""
3 }
4
5 var2file() {
6 local var
7 eval "var=\"\${$1}\""
8 if [ -n "$var" ]; then echo "$var" > "$2"; fi
9 }
10
11 isset() {
12 local var
13 eval "var=\"\${$1}\""
14 [ -n "$var" ]
15 }
16
17 trapret() {(
18 local retvals="$1"; shift
19 local cmd="$1"; shift
20 for retval in $(echo $retvals); do
21 local trap_$retval=1
22 done
23 "$cmd" "$@" || {
24 local retval="$?"
25 eval "trapped=\${trap_$retval}"
26 [ -n "$trapped" ] || {
27 return $retval
28 }
29 }
30 )}
31
32 md5s() {
33 which md5sum 2>&1 >/dev/null && md5sum "$@" | awk '{print $1}' || md5 "$@"
34 }
This page took 0.042284 seconds and 5 git commands to generate.