-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnato
More file actions
executable file
·65 lines (63 loc) · 1.55 KB
/
Copy pathnato
File metadata and controls
executable file
·65 lines (63 loc) · 1.55 KB
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
#!/usr/bin/env bash
# Convert given text to NATO alphabet.
#
# Usage:
#
# nato <TEXT>...
#
# Examples:
#
# nato hi there
#
# author: andreasl
# A case statement rather than an associative array, so this stays compatible
# with the Bash 3.2 that macOS ships.
to_nato() {
case "$1" in
[aA]) nato_char='Alfa' ;;
[bB]) nato_char='Bravo' ;;
[cC]) nato_char='Charlie' ;;
[dD]) nato_char='Delta' ;;
[eE]) nato_char='Echo' ;;
[fF]) nato_char='Foxtrot' ;;
[gG]) nato_char='Golf' ;;
[hH]) nato_char='Hotel' ;;
[iI]) nato_char='India' ;;
[jJ]) nato_char='Juliett' ;;
[kK]) nato_char='Kilo' ;;
[lL]) nato_char='Lima' ;;
[mM]) nato_char='Mike' ;;
[nN]) nato_char='November' ;;
[oO]) nato_char='Oscar' ;;
[pP]) nato_char='Papa' ;;
[qQ]) nato_char='Quebec' ;;
[rR]) nato_char='Romeo' ;;
[sS]) nato_char='Sierra' ;;
[tT]) nato_char='Tango' ;;
[uU]) nato_char='Uniform' ;;
[vV]) nato_char='Victor' ;;
[wW]) nato_char='Whiskey' ;;
[xX]) nato_char='X-ray' ;;
[yY]) nato_char='Yankee' ;;
[zZ]) nato_char='Zulu' ;;
1) nato_char='One' ;;
2) nato_char='Two' ;;
3) nato_char='Three' ;;
4) nato_char='Four' ;;
5) nato_char='Five' ;;
6) nato_char='Six' ;;
7) nato_char='Seven' ;;
8) nato_char='Eight' ;;
9) nato_char='Nine' ;;
0) nato_char='Zero' ;;
*) nato_char="$1" ;;
esac
}
for word in "$@"; do
out=()
for ((i = 0; i < ${#word}; i++)); do
to_nato "${word:i:1}"
out+=("$nato_char")
done
printf "%s\n" "${out[*]}"
done