Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to master grimoire by Pavel Vinogradov (7416f0b197310fe72230be87c83cd5288252db66)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Pavel Vinogradov <scm AT sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to master grimoire by Pavel Vinogradov (7416f0b197310fe72230be87c83cd5288252db66)
  • Date: Thu, 8 Dec 2022 03:04:06 +0000

GIT changes to master grimoire by Pavel Vinogradov <public AT sourcemage.org>:

ChangeLog | 4 ++++
FUNCTIONS | 24 ++++++++++++++++++++++--
2 files changed, 26 insertions(+), 2 deletions(-)

New commits:
commit 7416f0b197310fe72230be87c83cd5288252db66
Author: Xenanthropy <connerclere AT gmail.com>
Commit: Pavel Vinogradov <public AT sourcemage.org>

FUNCTIONS: refactor get_up_spell_name, support spells with a digit as the
first
character

diff --git a/ChangeLog b/ChangeLog
index d707d43..a5aa748 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2022-12-07 Conner Clere <connerclere AT gmail.com>
+ * FUNCTIONS: refactor get_up_spell_name to support spells with
+ a digit as the first character
+
2022-12-06 Conner Clere <connerclere AT gmail.com>
* windowmanagers/2bwm: new spell, a fast, floating window manager

diff --git a/FUNCTIONS b/FUNCTIONS
old mode 100755
new mode 100644
index d45e3f6..b1fb286
--- a/FUNCTIONS
+++ b/FUNCTIONS
@@ -813,10 +813,30 @@ function prepare_select_branch() {
}

#---
-## Get uppercase spell name with _ instead of -
+## Returns the spellname in all uppercase, and replacing hyphens with
underscores
+##
+## Also checks the first character of the spell and transliterates it if
+## it is a number (bash variables cannot start with a number)
#---
function get_up_spell_name() {
- echo ${1:-$SPELL} | tr '.+a-z-' '_XA-Z_'
+# Define an array containing the spelling of the numbers from 0 to 9
+ local NUMBER_SPELLINGS=("ZERO" "ONE" "TWO" "THREE" "FOUR" "FIVE" "SIX"
"SEVEN" "EIGHT" "NINE")
+ local spell=${1:-$SPELL}
+
+ # Check if the first character of the argument is a number
+ if [[ ${spell::1} =~ ^[0-9] ]]; then
+ # Transliterate the number to its spelling (e.g. 1 to ONE)
+ first_char=${NUMBER_SPELLINGS[${spell::1}]}
+ # Replace the first character of the argument with the transliterated
spelling
+ result="${first_char}${spell:1}"
+ else
+ # If the first character is not a number, use the argument as is
+ result=$spell
+ fi
+
+ # Replaces the hyphens with underscores, then echos $argument in all
uppercase
+ result=${result//-/_}
+ echo "${result^^}"
}

#---



  • [SM-Commit] GIT changes to master grimoire by Pavel Vinogradov (7416f0b197310fe72230be87c83cd5288252db66), Pavel Vinogradov, 12/07/2022

Archive powered by MHonArc 2.6.24.

Top of Page