1# export-y.tst: yash-specific test of the export built-in
2
3# XXX: missing test 'printing all exported variables'
4
5test_oE -e 0 'printing specific exported variables'
6export a=A f=FOO
7export -p a f
8__IN__
9export a=A
10export f=FOO
11__OUT__
12
13test_OE -e 0 'without argument, -p is assumed'
14export >withoutp.out
15export -p >withp.out
16diff withoutp.out withp.out
17__IN__
18
19test_oE -e 0 'assigning empty value'
20export a=
21export -p a
22__IN__
23export a=''
24__OUT__
25
26test_oE 'exporting with -p'
27export -p a=A
28export -p a
29__IN__
30export a=A
31__OUT__
32
33test_oE 'un-exporting'
34export a=A
35export -X a
36sh -c 'echo ${a-unset}'
37__IN__
38unset
39__OUT__
40
41test_Oe -e 1 'assigning to read-only variable'
42readonly a=A
43export a=X
44__IN__
45export: $a is read-only
46__ERR__
47
48test_oE 'exporting before separate assignment'
49export a
50a=A
51sh -c 'echo $a'
52__IN__
53A
54__OUT__
55
56test_O -d -e 1 'assigning to ill-named variable'
57export =A
58__IN__
59
60(
61posix="true"
62
63test_Oe -e 2 'invalid option -r (POSIX)'
64export -r
65__IN__
66export: `-r' is not a valid option
67__ERR__
68#'
69#`
70
71test_Oe -e 2 'invalid option -X (POSIX)'
72export -X
73__IN__
74export: `-X' is not a valid option
75__ERR__
76#'
77#`
78
79)
80
81test_Oe -e 2 'invalid option -z'
82export -z
83__IN__
84export: `-z' is not a valid option
85__ERR__
86#'
87#`
88
89test_Oe -e 2 'invalid option --xxx'
90export --no-such=option
91__IN__
92export: `--no-such=option' is not a valid option
93__ERR__
94#'
95#`
96
97test_O -d -e 1 'printing to closed stream'
98export >&-
99__IN__
100
101test_Oe -e 1 'printing non-existing variable'
102unset a
103export -p a
104__IN__
105export: no such variable $a
106__ERR__
107
108# vim: set ft=sh ts=8 sts=4 sw=4 noet:
109