~ubuntu-branches/ubuntu/trusty/bash/trusty-security

« back to all changes in this revision

Viewing changes to tests/array6.sub

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2014-03-03 22:52:05 UTC
  • mfrom: (1.3.5) (2.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20140303225205-87ltrt5kspeq0g1b
Tags: 4.3-1ubuntu1
* Merge with Debian; remaining changes:
  - skel.bashrc:
    - Run lesspipe.
    - Enable ls aliases.
    - Set options in ll alias to -alF.
    - Define an alert alias.
    - Enabled colored grep aliases.
  - etc.bash.bashrc:
    - Add sudo hint.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# test cases for array quoting and escaping fixed post bash-3.2-release
 
2
 
 
3
oIFS="$IFS"
 
4
 
 
5
a=(a b c)
 
6
echo ${a[@]}
 
7
 
 
8
a2=("${a[@]/#/"-iname '"}")
 
9
recho "${a2[@]}"
 
10
 
 
11
echo "${dbg-"'hey'"}"
 
12
echo "${dbg-"hey"}"
 
13
echo "${dbg-'"'hey}"
 
14
echo "${dbg-'"hey'}"
 
15
 
 
16
unset a a2
 
17
 
 
18
IFS=
 
19
a2=(${a[@]/#/"-iname '"})
 
20
recho "${a2[@]}"
 
21
 
 
22
IFS="$oIFS"
 
23
unset a a2
 
24
 
 
25
a=('a b' 'c d' 'e f')
 
26
 
 
27
recho ${a[@]:1:2}
 
28
recho "${a[@]:1:2}"
 
29
 
 
30
IFS=
 
31
recho ${a[@]:1:2}
 
32
recho "${a[@]:1:2}"
 
33
 
 
34
IFS="$oIFS"
 
35
unset a a2
 
36
 
 
37
a=(abc def)
 
38
 
 
39
# Prevent word splitting
 
40
#IFS= 
 
41
 
 
42
a2=("${a[@]/#/"-iname '"}") 
 
43
recho "${a2[@]}"
 
44
 
 
45
eval a2=("${a[@]/#/\"-iname \'\"}") 
 
46
recho "${a2[@]}"
 
47
 
 
48
eval a2=("${a[@]/#/"-iname '"}") 
 
49
recho "${a2[@]}"
 
50
 
 
51
a2=("${a[@]/#/-iname \'}") 
 
52
recho "${a2[@]}"
 
53
 
 
54
eval a2=("${a[@]/#/-iname \'}") 
 
55
recho "${a2[@]}"
 
56
 
 
57
set -- abc def
 
58
 
 
59
a2=("${@/#/"-iname '"}") 
 
60
recho "${a2[@]}"
 
61
 
 
62
eval a2=("${@/#/\"-iname \'\"}") 
 
63
recho "${a2[@]}"
 
64
 
 
65
eval a2=("${@/#/"-iname '"}") 
 
66
recho "${a2[@]}"
 
67
 
 
68
unset a a2
 
69
 
 
70
IFS=
 
71
pat=('*.*')
 
72
case $(ls ${pat[@]} 2>/dev/null) in
 
73
'')     echo '*.* BAD' ;;
 
74
*)      echo '*.* OK' ;;
 
75
esac
 
76
 
 
77
IFS="$oIFS"
 
78
unset a a2 pat
 
79
 
 
80
IFS=
 
81
 
 
82
s='abc'
 
83
 
 
84
set - ${s/b/1 2 3}
 
85
echo $#
 
86
echo "$1"
 
87
 
 
88
IFS="$oIFS"
 
89
unset s
 
90
 
 
91
set -- ab cd ef
 
92
foo="var with spaces"
 
93
 
 
94
IFS=
 
95
recho $foo
 
96
recho "$foo"
 
97
 
 
98
recho ${foo}"$@"
 
99
recho ${foo}$@
 
100
 
 
101
array=(ab cd ef)
 
102
recho ${foo}"${array[@]}"
 
103
recho ${foo}${array[@]}
 
104
 
 
105
recho $(echo $foo)"$@"
 
106
recho $(echo $foo)$@
 
107
 
 
108
a=('word1 with spaces' 'word2 with spaces')
 
109
set - ${a[@]/word/element}
 
110
echo $#
 
111
recho "$@"
 
112
recho $@
 
113
 
 
114
IFS="$oIFS"
 
115
unset a a2 array foo