-
Notifications
You must be signed in to change notification settings - Fork 4
/
array.test.sh
executable file
·100 lines (79 loc) · 2.5 KB
/
array.test.sh
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
#!/usr/bin/env bash
. include array exceptions
__CATCH_exception()
{
echo
echo Exception: "$*"
echo
exit 1
}
array.new ports
ports[echo]="Echo"
ports[discard]="Discard"
ports[daytime]="Daytime (RFC 867)"
ports[chargen]="Character Generator"
ports[ftp-data]="File Transfer [Default Data]"
ports[ftp]="File Transfer [Control]"
ports[ssh]="SSH Remote Login Protocol"
ports[telnet]="Telnet"
ports[smtp]="Simple Mail Transfer"
ports.set squid "Squid Proxy"
echo "The list has `ports.length` entries."
echo "The full name for 'ssh' is `ports.get ssh`"
ports.find "Telnet" ports && echo "There is an entry ($KEY) for Telnet"
array.array_search "Telnet" ports && echo "There is an entry ($KEY) for Gopher"
echo
echo "These are all the known ports:"
echo
ports.foreach
do
printf "%10s %s\n" $key "${ports[$key]}"
done
array.keys ports
for key in "${KEYS[@]}"
do
printf "%10s %s\n" $key "${ports[$key]}"
done
declare -p ports
: <<'OUTPUT'
The list has 9 entries.
The full name for 'ssh' is SSH Remote Login Protocol
These are all the known ports:
chargen Character Generator
daytime Daytime (RFC 867)
telnet Telnet
echo Echo
ftp-data File Transfer [Default Data]
ftp File Transfer [Control]
ssh SSH Remote Login Protocol
smtp Simple Mail Transfer
discard Discard
OUTPUT
## Wierd things
: <<'WIERD'
root@proxy ~/dev/gsm/bash $ declare -a list=(cat dog fish)
+ list=(cat dog fish)
+ declare -a list
root@proxy ~/dev/gsm/bash $ declare -p list
+ declare -p list
declare -a list='([0]="cat" [1]="dog" [2]="fish")'
root@proxy ~/dev/gsm/bash $ declare -a list='([0]="cat" [1]="dog" [2]="fish")'
+ declare -a 'list=([0]="cat" [1]="dog" [2]="fish")'
root@proxy ~/dev/gsm/bash $ declare -p list
+ declare -p list
declare -a list='([0]="cat" [1]="dog" [2]="fish")'
root@proxy ~/dev/gsm/bash $
root@proxy ~/dev/gsm/bash $ declare -a list='("cat" "dog" "fish")'
+ declare -a 'list=("cat" "dog" "fish")'
root@proxy ~/dev/gsm/bash $ declare -p list
+ declare -p list
declare -a list='([0]="cat" [1]="dog" [2]="fish")'
root@proxy ~/dev/gsm/bash $ declare -a list='(cat dog fish)'
+ declare -a 'list=(cat dog fish)'
root@proxy ~/dev/gsm/bash $ declare -a 'list=(cat dog fish)'
+ declare -a 'list=(cat dog fish)'
root@proxy ~/dev/gsm/bash $ declare -p list
+ declare -p list
declare -a list='([0]="cat" [1]="dog" [2]="fish")'
root@proxy ~/dev/gsm/bash $
WIERD