commit: 1076ace3242611cb6d125f3d18700d363e16be57
Author: Martin Väth <martin <AT> mvath <DOT> de>
AuthorDate: Fri Aug 17 11:11:45 2018 +0000
Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> 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 <robbat2 <AT> 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