Root/include/shell.sh

1getvar() {
2    eval "echo \"\${$1}\""
3}
4
5var2file() {
6    local var
7    eval "var=\"\${$1}\""
8    if [ -n "$var" ]; then echo "$var" > "$2"; fi
9}
10
11isset() {
12    local var
13    eval "var=\"\${$1}\""
14    [ -n "$var" ]
15}
16
17trapret() {(
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
32md5s() {
33    cat "$@" | (
34        md5sum 2>/dev/null ||
35        md5
36    ) | awk '{print $1}'
37}
38

Archive Download this file



interactive