diff options
author | Martin Väth <martin@mvath.de> | 2018-08-17 13:11:45 +0200 |
---|---|---|
committer | Robin H. Johnson <robbat2@gentoo.org> | 2019-04-20 21:15:51 -0700 |
commit | 1076ace3242611cb6d125f3d18700d363e16be57 (patch) | |
tree | 9d2198e5af95913fed126d799e33c221cb36983e /sh | |
parent | init.d/net.lo: add a configurable presence timeout (diff) | |
download | netifrc-1076ace3242611cb6d125f3d18700d363e16be57.tar.gz netifrc-1076ace3242611cb6d125f3d18700d363e16be57.tar.bz2 netifrc-1076ace3242611cb6d125f3d18700d363e16be57.zip |
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@gentoo.org>
Diffstat (limited to 'sh')
-rw-r--r-- | sh/functions.sh | 10 |
1 files changed, 9 insertions, 1 deletions
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 |