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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id EFC46138335 for ; Sun, 21 Apr 2019 04:17:58 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B8436E0B89; Sun, 21 Apr 2019 04:17:57 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id A0F62E0B43 for ; Sun, 21 Apr 2019 04:17:57 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 5AC18341BB0 for ; Sun, 21 Apr 2019 04:17:56 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 036C25B7 for ; Sun, 21 Apr 2019 04:17:55 +0000 (UTC) From: "Robin H. Johnson" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Robin H. Johnson" Message-ID: <1555820151.1076ace3242611cb6d125f3d18700d363e16be57.robbat2@OpenRC> Subject: [gentoo-commits] proj/netifrc:master commit in: sh/ X-VCS-Repository: proj/netifrc X-VCS-Files: sh/functions.sh X-VCS-Directories: sh/ X-VCS-Committer: robbat2 X-VCS-Committer-Name: Robin H. Johnson X-VCS-Revision: 1076ace3242611cb6d125f3d18700d363e16be57 X-VCS-Branch: master Date: Sun, 21 Apr 2019 04:17:55 +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: 5bf05219-7d4a-44e0-b3aa-0765914f5307 X-Archives-Hash: cc49bd40d0d9decd0c5d13811154cf56 commit: 1076ace3242611cb6d125f3d18700d363e16be57 Author: Martin Väth mvath de> AuthorDate: Fri Aug 17 11:11:45 2018 +0000 Commit: Robin H. Johnson gentoo org> CommitDate: Sun Apr 21 04:15:51 2019 +0000 URL: https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=1076ace3 sh/functions.sh: Avoid bashisms in shell_var() POSIX shells do not provide a substitution operation ${..//..} Negated character classes are marked by [!..] and not [^..] in POSIX. Signed-off-by: Robin H. Johnson gentoo.org> sh/functions.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sh/functions.sh b/sh/functions.sh index 5895a90..832e58e 100644 --- a/sh/functions.sh +++ b/sh/functions.sh @@ -36,7 +36,15 @@ if [ "$INIT" != "openrc" ]; then shell_var() { local output= sanitized_arg= for arg; do - sanitized_arg="${arg//[^a-zA-Z0-9_]/_}" + sanitized_arg=$arg + while :; do + case $sanitized_arg in + *[!a-zA-Z0-9_]*) + sanitized_arg=${sanitized_arg%%[!a-zA-Z0-9_]*}_${sanitized_arg#*[!a-zA-Z0-9_]} + continue;; + esac + break + done if [ x"$output" = x"" ] ; then output=$sanitized_arg else