]> git.ipfire.org Git - thirdparty/bash.git/blob - tests/nquote1.tests
bash-5.1 distribution sources and documentation
[thirdparty/bash.git] / tests / nquote1.tests
1 # This program is free software: you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation, either version 3 of the License, or
4 # (at your option) any later version.
5 #
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # GNU General Public License for more details.
10 #
11 # You should have received a copy of the GNU General Public License
12 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 #
14 a=$'a\001b'
15
16 set $a
17
18 b=$a
19 c=$1
20 d="$1"
21
22 e=$'uv\001\001wx'
23
24 recho a $a ${#a}
25 recho 1 $1 ${#1}
26 recho b $b ${#b}
27 recho c $c ${#c}
28 recho d $d ${#d}
29
30 recho a ${a} ${#a}
31 recho 1 ${1} ${#1}
32 recho b ${b} ${#b}
33 recho c ${c} ${#c}
34 recho d ${d} ${#d}
35
36 recho a "$a" ${#a}
37 recho 1 "$1" ${#1}
38 recho b "$b" ${#b}
39 recho c "$c" ${#c}
40 recho d "$d" ${#d}
41
42 recho a "${a}" ${#a}
43 recho 1 "${1}" ${#1}
44 recho b "${b}" ${#b}
45 recho c "${c}" ${#c}
46 recho d "${d}" ${#d}
47
48 set $e
49
50 recho e1 ${e:1:3}
51 recho e2 "${e:1:3}"
52 recho e3 ${1:1:3}
53 recho e4 "${1:1:3}"
54
55 arr[0]=$e
56 arr[1]=$e
57
58 recho a1 ${arr:0:4}
59 recho a2 "${arr:0:4}"
60
61 recho a3 ${arr[@]:0:2}
62 recho a4 "${arr[@]:0:2}"
63
64 set $e $e
65
66 recho p1 ${@:1:2}
67 recho p2 "${@:1:2}"
68
69 recho p1 ${*:1:2}
70 recho p2 "${*:1:2}"
71
72 recho $e
73
74 recho 'uv\ 1\ 1wx'
75
76 f='uv\ 1\ 1wx'
77
78 recho $f
79
80 echo -en "\01" | cat -v
81 echo
82
83 huhu() { echo "$1"; };
84
85 huhu $(echo -en "\01") | cat -v
86 huhu $(echo -en "\02") | cat -v
87
88 f=$'uv\001w\001xy'
89
90 set $f $f
91
92 recho f1 ${f:1:3}
93 recho f2 "${f:1:3}"
94
95 arr[0]=$f
96 arr[1]=$f
97
98 recho a1 ${arr:0:4}
99 recho a2 "${arr:0:4}"
100 recho a3 ${arr[0]:0:4}
101 recho a4 "${arr[0]:0:4}"
102
103 recho e1 ${f:0:4}
104 recho e2 "${f:0:4}"
105
106 recho d1 ${1:2:2}
107 recho d2 "${1:2:2}"
108
109 recho @1 ${@:1:2}
110 recho @2 "${@:1:2}"
111
112 declare -A assoc
113 assoc=( [0]=$e [1]=$e )
114
115 recho aa1 ${assoc:0:4}
116 recho aa2 "${assoc:0:4}"
117
118 recho aa3 ${assoc[@]:0:2}
119 recho aa4 "${assoc[@]:0:2}"