From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 25B72159C9B for ; Sun, 11 Aug 2024 10:11:13 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 6C3282BC04A; Sun, 11 Aug 2024 10:11:12 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 4B6B62BC01C for ; Sun, 11 Aug 2024 10:11:12 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 81B0F340BDE for ; Sun, 11 Aug 2024 10:11:11 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id ABC111ED7 for ; Sun, 11 Aug 2024 10:11:09 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1723371056.d5b850a938c5f70c33891fa08c7224dce96294e0.sam@gentoo> Subject: [gentoo-commits] proj/gentoo-functions:master commit in: / X-VCS-Repository: proj/gentoo-functions X-VCS-Files: functions.sh test-functions X-VCS-Directories: / X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: d5b850a938c5f70c33891fa08c7224dce96294e0 X-VCS-Branch: master Date: Sun, 11 Aug 2024 10:11:09 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 925b1276-b6fb-412a-8723-c05e3a0a8634 X-Archives-Hash: e791a788a6db085a8a0f23078d9af012 commit: d5b850a938c5f70c33891fa08c7224dce96294e0 Author: Kerin Millar plushkava net> AuthorDate: Tue Aug 6 06:47:13 2024 +0000 Commit: Sam James gentoo 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 plushkava.net> Signed-off-by: Sam James 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