blob: c530dfa2c27f5db2852e4480dafdbf8dc1b5a034 (
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
67
68
69
70
71
72
73
74
75
76
|
# $OpenBSD: varfunction.sh,v 1.1 2003/12/15 05:28:40 otto Exp $
#
# Calling
#
# FOO=bar f
#
# where f is a ksh style function, should not set FOO in the current env.
# If f is a bourne style function, FOO should be set. Furthermore,
# the function should receive a correct value of FOO. Additionally,
# setting FOO in the function itself should not change the value in
# global environment.
#
# Inspired by PR 2450.
#
function k {
if [ x$FOO != xbar ]; then
echo 1
return 1
fi
x=$(env | grep FOO)
if [ "x$x" != "xFOO=bar" ]; then
echo 2
return 1;
fi
FOO=foo
return 0
}
b () {
if [ x$FOO != xbar ]; then
echo 3
return 1
fi
x=$(env | grep FOO)
if [ "x$x" != "xFOO=bar" ]; then
echo 4
return 1;
fi
FOO=foo
return 0
}
FOO=bar k
if [ $? != 0 ]; then
exit 1
fi
if [ x$FOO != x ]; then
exit 1
fi
FOO=bar b
if [ $? != 0 ]; then
exit 1
fi
if [ x$FOO != xbar ]; then
exit 1
fi
FOO=barbar
FOO=bar k
if [ $? != 0 ]; then
exit 1
fi
if [ x$FOO != xbarbar ]; then
exit 1
fi
FOO=bar b
if [ $? != 0 ]; then
exit 1
fi
if [ x$FOO != xbar ]; then
exit 1
fi
|