Prefer tr to ${char^^}, which does not work on older bash versions (#303)

* Prefer `tr` to ${char^^}, which does not work on older bash versions

* Update CHANGELOG.md

---------

Co-authored-by: ReFil <[email protected]>
This commit is contained in:
Jim Jowdy
2023-12-27 12:59:59 +00:00
committed by GitHub
co-authored by ReFil
parent 7287c4daf6
commit 1728a660ce
2 changed files with 10 additions and 2 deletions
+8 -1
View File
@@ -5,11 +5,18 @@ date=$(date -u +"%Y%m%d")
branch=${1:-$(git rev-parse --abbrev-ref HEAD | cut -c1-4)}
commit=${2:-$(git rev-parse --short HEAD)}
uppercase_char() {
local char=$1
(echo $char | tr '[a-z]' '[A-Z]' 2> /dev/null) || echo "${char^^}"
}
# Function to transform characters to ZMK key behaviours
transform_char() {
local char=$1
if [[ $char =~ [A-Za-z] ]]; then
echo "<&kp ${char^^}>, "
echo "<&kp $(uppercase_char $char)>, "
elif [[ $char =~ [0-9] ]]; then
echo "<&kp N${char}>, "
elif [ "$char" = "." ]; then