Created
October 28, 2022 17:16
-
-
Save CryptoFewka/92b22a9c5b67c47c9e9e5e14da8dba30 to your computer and use it in GitHub Desktop.
bash script to convert text to morse code written in spaces and tabs. For reasons.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
#set -x | |
# | |
# forked from jessebutryn/morse.sh | |
####################################### | |
declare -A whitespace | |
whitespace[0]=' ' | |
whitespace[1]=' ' | |
whitespace[2]=' ' | |
whitespace[3]=' ' | |
whitespace[4]=' ' | |
whitespace[5]=' ' | |
whitespace[6]=' ' | |
whitespace[7]=' ' | |
whitespace[8]=' ' | |
whitespace[9]=' ' | |
whitespace[A]=' ' | |
whitespace[B]=' ' | |
whitespace[C]=' ' | |
whitespace[D]=' ' | |
whitespace[E]=' ' | |
whitespace[F]=' ' | |
whitespace[G]=' ' | |
whitespace[H]=' ' | |
whitespace[I]=' ' | |
whitespace[J]=' ' | |
whitespace[K]=' ' | |
whitespace[L]=' ' | |
whitespace[M]=' ' | |
whitespace[N]=' ' | |
whitespace[O]=' ' | |
whitespace[P]=' ' | |
whitespace[Q]=' ' | |
whitespace[R]=' ' | |
whitespace[S]=' ' | |
whitespace[T]=' ' | |
whitespace[U]=' ' | |
whitespace[V]=' ' | |
whitespace[W]=' ' | |
whitespace[X]=' ' | |
whitespace[Y]=' ' | |
whitespace[Z]=' ' | |
whitespace[.]=' ' | |
whitespace[,]=' ' | |
whitespace[;]=' ' | |
whitespace[:]=' ' | |
whitespace[-]=' ' | |
whitespace[/]=' ' | |
whitespace[\']=' ' | |
whitespace[\"]=' ' | |
####################################### | |
while read -rN1 c; do | |
c=${c^} | |
if [[ $c == $'\n' ]]; then | |
printf '\n' | |
elif [[ $c == ' ' ]]; then | |
printf ' ' | |
else | |
printf '%s ' "${whitespace[$c]}" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment