From 0cefd82f9bf08c319b46215c2f0e96d1cd243a9f Mon Sep 17 00:00:00 2001 From: Matthias Kruk Date: Tue, 20 Apr 2021 22:30:44 +0900 Subject: [PATCH] include/in: Fix bug in is_alpha() and is_alnum() The is_alpha() and is_alnum() functions fail to recognize strings containing mixed case and digits (in the case of the latter). This commit fixes the implementations by making perform the check with a regular expression instead of delegating the work to is_upper(), is_lower(), and is_digits(). --- include/is.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/is.sh b/include/is.sh index d0f804b..9384602 100644 --- a/include/is.sh +++ b/include/is.sh @@ -57,7 +57,7 @@ is_alpha() { str="$1" - if is_upper "$str" || is_lower "$str"; then + if [[ "$str" =~ ^[a-zA-Z]+$ ]]; then return 0 fi @@ -69,7 +69,7 @@ is_alnum() { str="$1" - if is_alpha "$str" || is_digits "$str"; then + if [[ "$str" =~ ^[a-zA-Z0-9]+ ]]; then return 0 fi -- 2.47.3