bashrc/.bashrc.d/phsp.bash

49 lines
980 B
Bash

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
}