]> git.ipfire.org Git - thirdparty/bash.git/blob - tests/dollar-at-star11.sub
bash-5.2 distribution sources and documentation
[thirdparty/bash.git] / tests / dollar-at-star11.sub
1 a[0]='/'
2 set -- /
3
4 # these should all result in the empty (null) string
5
6 recho "${a[0]%?}"
7 recho "${a[*]%?}"
8 recho "${a[@]%?}"
9
10 recho "${*%?}"
11 recho "${@%?}"
12
13 recho "${a[0]#?}"
14 recho "${a[*]#?}"
15 recho "${a[@]#?}"
16
17 recho "${*#?}"
18 recho "${@#?}"
19
20 recho "${a[0]/\//}"
21 recho "${a[*]/\//}"
22 recho "${a[@]/\//}"
23
24 recho "${*/\//}"
25 recho "${@/\//}"
26
27 recho "${a[0]:1:1}"
28 # these next four will all echo /
29
30 # arrays are zero-based
31 recho "${a[*]:0:1}"
32 recho "${a[@]:0:1}"
33 # but the positional parameters start at 1
34 recho "${*:1:1}"
35 recho "${@:1:1}"
36
37 a[0]=''
38 set -- ''
39
40 # arrays are zero-based
41 recho "${a[*]:0:1}"
42 recho "${a[@]:0:1}"
43
44 recho "${*:1:1}"
45 recho "${@:1:1}"
46
47 # these should all result in the empty (null) string, or quoted as such
48
49 recho "${a[0]@Q}"
50 recho "${a[*]@Q}"
51 recho "${a[@]@Q}"
52
53 recho "${*@Q}"
54 recho "${@@Q}"
55
56 recho "${a[0]@L}"
57 recho "${a[*]@L}"
58 recho "${a[@]@L}"
59
60 recho "${*@L}"
61 recho "${@@L}"
62
63 # examples from the bug report
64 unset -v a
65
66 a[0]='/'
67 for i in "${a[@]%/}"; do recho "$i"; done
68
69 a[0]=''
70 for i in "${a[@]}"; do recho "$i"; done
71
72 a[0]='/'
73 a[1]="//"
74 for i in "${a[@]%/}"; do recho "$i"; done
75
76 unset -v x y
77 x=('/')
78 y=("${x[@]%/}")
79
80 echo "${#x[@]}:${#y[@]}"