Added phsp.bash, a simple/stupid NATO Phonetic Alphabet speller utility

This commit is contained in:
David Thurstenson 2022-04-06 13:34:42 -05:00
parent 39a834cbed
commit 03ef238a33
1 changed files with 48 additions and 0 deletions

48
.bashrc.d/phsp.bash Normal file
View File

@ -0,0 +1,48 @@
phsp() {
local input="$*"
local char
local out
# Iterate over each character in the string
for i in $(seq 0 ${#input}); do
# Get the current character using parameter expansion
char=${input:$i:1}
# Match against alphabet (using uppercase of variable)
case ${char^^} in
A) out="Alfa" ;;
B) out="Bravo" ;;
C) out="Charlie" ;;
D) out="Delta" ;;
E) out="Echo" ;;
F) out="Foxtrot" ;;
G) out="Golf" ;;
H) out="Hotel" ;;
I) out="India" ;;
J) out="Juliett" ;;
K) out="Kilo" ;;
L) out="Lima" ;;
M) out="Mike" ;;
N) out="November" ;;
O) out="Oscar" ;;
P) out="Papa" ;;
Q) out="Quebec" ;;
R) out="Romeo" ;;
S) out="Sierra" ;;
T) out="Tango" ;;
U) out="Uniform" ;;
V) out="Victor" ;;
W) out="Whiskey" ;;
X) out="X-ray" ;;
Y) out="Yankee" ;;
Z) out="Zulu" ;;
[[:space:]]) out="" ;;
*) out=""
esac
if [ "$out" ]; then
printf "%s: %s\n" "$char" "$out"
else
printf "\n"
fi
done
}