summaryrefslogtreecommitdiffstats
path: root/tests/nquote1.tests
blob: f47ab54eb9de9816d4d838d2d3d4c2d8effb80ab (plain)
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
a=$'a\001b'

set $a

b=$a
c=$1
d="$1"

e=$'uv\001\001wx'

recho a $a ${#a}
recho 1 $1 ${#1}
recho b $b ${#b}
recho c $c ${#c}
recho d $d ${#d}

recho a ${a} ${#a}
recho 1 ${1} ${#1}
recho b ${b} ${#b}
recho c ${c} ${#c}
recho d ${d} ${#d}

recho a "$a" ${#a}
recho 1 "$1" ${#1}
recho b "$b" ${#b}
recho c "$c" ${#c}
recho d "$d" ${#d}

recho a "${a}" ${#a}
recho 1 "${1}" ${#1}
recho b "${b}" ${#b}
recho c "${c}" ${#c}
recho d "${d}" ${#d}

set $e

recho e1 ${e:1:3}
recho e2 "${e:1:3}"
recho e3 ${1:1:3}
recho e4 "${1:1:3}"

arr[0]=$e
arr[1]=$e

recho a1 ${arr:0:4}
recho a2 "${arr:0:4}"

recho a3 ${arr[@]:0:2}
recho a4 "${arr[@]:0:2}"

set $e $e

recho p1 ${@:1:2}
recho p2 "${@:1:2}"

recho p1 ${*:1:2}
recho p2 "${*:1:2}"

recho $e

recho 'uvwx'

f='uvwx'

recho $f

echo -en "\01" | cat -v
echo

huhu() { echo "$1"; };

huhu $(echo -en "\01") | cat -v
huhu $(echo -en "\02") | cat -v

f=$'uv\001w\001xy'

set $f $f

recho f1 ${f:1:3}
recho f2 "${f:1:3}"

arr[0]=$f
arr[1]=$f

recho a1 ${arr:0:4}
recho a2 "${arr:0:4}"
recho a3 ${arr[0]:0:4}
recho a4 "${arr[0]:0:4}"

recho e1 ${f:0:4}
recho e2 "${f:0:4}"

recho d1 ${1:2:2}
recho d2 "${1:2:2}"

recho @1 ${@:1:2}
recho @2 "${@:1:2}"

declare -A assoc
assoc=( [0]=$e [1]=$e )

recho aa1 ${assoc:0:4}
recho aa2 "${assoc:0:4}"

recho aa3 ${assoc[@]:0:2}
recho aa4 "${assoc[@]:0:2}"