blob: 88f1d31396069bde9a77d91f8109e47393dc7667 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
foo()
{
local var=1
bar var
}
bar(string ref)
{
local var=2
eval "${ref}=3"
}
foo()
{
local var=1
bar &var
}
bar(string ref)
{
local var=2
!ref=3
}
__ref()
{
__var=${1}
case " ${__fn_vars} " in *" ${__var} "*)
printf '__fn_vars_%d_%s' ${__sp} "${__var}"
return 0
;; esac
eval "__val=\${__${__prev_tu}_static_vars}"
case " ${__val} " in *" ${__var} "*)
printf '__fn_vars_%d_%s' ${__sp} "${__var}"
return 0
;; esac
}
__derefset()
{
__var=${1}
case "${__var}" in
*[!A-Za-z0-9_]*)
printf 'Error: Invalid reference variable\n' >&2
exit 1
;;
'__fn_vars_'[A-Za-z_]*)
;;
*)
printf 'Error: Invalid reference variable\n' >&2
exit 1
;;
esac
eval "printf '%s' \${${__var#__fn_vars_}}"
}
|