commit:     d5b850a938c5f70c33891fa08c7224dce96294e0
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Tue Aug  6 06:47:13 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Aug 11 10:10:56 2024 +0000
URL:        
https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=d5b850a9

Avoid a subshell for is_identifier()

Also, extend the coverage of the test suite a little further.

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 functions.sh   |  8 ++++----
 test-functions | 10 +++++++++-
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/functions.sh b/functions.sh
index 2174fec..b591acb 100644
--- a/functions.sh
+++ b/functions.sh
@@ -242,12 +242,12 @@ hr()
 # Determines whether the first parameter is a valid identifier (variable name).
 #
 is_identifier()
-(
-       LC_ALL=C
+{
        case $1 in
-               ''|_|[[:digit:]]*|*[!_[:alnum:]]*) false
+               
''|_|[0123456789]*|*[!_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz]*)
+                       false
        esac
-)
+}
 
 #
 # Determines whether the first parameter is a valid integer. A leading

diff --git a/test-functions b/test-functions
index 2f831c8..fd3f176 100755
--- a/test-functions
+++ b/test-functions
@@ -310,7 +310,15 @@ test_is_identifier() {
                eq  0  a_a   \
                eq  0  a_Z   \
                eq  0  Z_a   \
-               eq  0  Z_Z
+               eq  0  Z_Z   \
+               eq  0   a0   \
+               eq  0   a9   \
+               eq  0   Z0   \
+               eq  0   Z9   \
+               eq  0  a_0   \
+               eq  0  a_9   \
+               eq  0  Z_0   \
+               eq  0  Z_9
 
        callback() {
                shift

Reply via email to