File: export-y.tst

package info (click to toggle)
yash 2.60-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,152 kB
  • sloc: ansic: 34,578; makefile: 851; sh: 808; sed: 16
file content (115 lines) | stat: -rw-r--r-- 1,706 bytes parent folder | download
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# export-y.tst: yash-specific test of the export built-in

# XXX: missing test 'printing all exported variables'

test_oE -e 0 'printing specific exported variables'
export a=A f=FOO
export -p a f
__IN__
export a=A
export f=FOO
__OUT__

test_OE -e 0 'without argument, -p is assumed'
export >withoutp.out
export -p >withp.out
diff withoutp.out withp.out
__IN__

test_oE -e 0 'assigning empty value'
export a=
export -p a
__IN__
export a=''
__OUT__

test_oE 'exporting with -p'
export -p a=A
export -p a
__IN__
export a=A
__OUT__

test_oE 'un-exporting'
export a=A
export -X a
sh -c 'echo ${a-unset}'
__IN__
unset
__OUT__

test_Oe -e 1 'assigning to read-only variable'
readonly a=A
export a=X
__IN__
export: $a is read-only
__ERR__

test_oE 'exporting before separate assignment'
export a
a=A
sh -c 'echo $a'
__IN__
A
__OUT__

test_oE -e 0 'separator preceding scalar variable name starting with -' -e
export -- -a=1
export -p -- -a
__IN__
export -- -a=1
__OUT__

test_O -d -e 1 'assigning to ill-named variable'
export =A
__IN__

(
posix="true"

test_Oe -e 2 'invalid option -r (POSIX)'
export -r
__IN__
export: `-r' is not a valid option
__ERR__
#'
#`

test_Oe -e 2 'invalid option -X (POSIX)'
export -X
__IN__
export: `-X' is not a valid option
__ERR__
#'
#`

)

test_Oe -e 2 'invalid option -z'
export -z
__IN__
export: `-z' is not a valid option
__ERR__
#'
#`

test_Oe -e 2 'invalid option --xxx'
export --no-such=option
__IN__
export: `--no-such=option' is not a valid option
__ERR__
#'
#`

test_O -d -e 1 'printing to closed stream'
export >&-
__IN__

test_Oe -e 1 'printing non-existing variable'
unset a
export -p a
__IN__
export: no such variable $a
__ERR__

# vim: set ft=sh ts=8 sts=4 sw=4 et: