|
|
|
@ -24,7 +24,7 @@ debug_on() {
@@ -24,7 +24,7 @@ debug_on() {
|
|
|
|
|
|
|
|
|
|
# returns OK if $1 contains literal string $2 (and isn't empty) |
|
|
|
|
strstr() { |
|
|
|
|
[ "${1##*"$2"*}" != "$1" ] |
|
|
|
|
[ "${1##*$2*}" != "$1" ] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
# returns OK if $1 matches (completely) glob pattern $2 |
|
|
|
@ -43,18 +43,18 @@ strglobin() {
@@ -43,18 +43,18 @@ strglobin() {
|
|
|
|
|
|
|
|
|
|
# returns OK if $1 contains literal string $2 at the beginning, and isn't empty |
|
|
|
|
str_starts() { |
|
|
|
|
[ "${1#"$2"*}" != "$1" ] |
|
|
|
|
[ "${1#$2*}" != "$1" ] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
# returns OK if $1 contains literal string $2 at the end, and isn't empty |
|
|
|
|
str_ends() { |
|
|
|
|
[ "${1%*"$2"}" != "$1" ] |
|
|
|
|
[ "${1%*$2}" != "$1" ] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
trim() { |
|
|
|
|
local var="$*" |
|
|
|
|
var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters |
|
|
|
|
var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters |
|
|
|
|
var="${var#${var%%[![:space:]]*}}" # remove leading whitespace characters |
|
|
|
|
var="${var%${var##*[![:space:]]}}" # remove trailing whitespace characters |
|
|
|
|
printf "%s" "$var" |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -108,9 +108,9 @@ str_replace() {
@@ -108,9 +108,9 @@ str_replace() {
|
|
|
|
|
local out='' |
|
|
|
|
|
|
|
|
|
while strstr "${in}" "$s"; do |
|
|
|
|
chop="${in%%"$s"*}" |
|
|
|
|
chop="${in%%$s*}" |
|
|
|
|
out="${out}${chop}$r" |
|
|
|
|
in="${in#*"$s"}" |
|
|
|
|
in="${in#*$s}" |
|
|
|
|
done |
|
|
|
|
echo "${out}${in}" |
|
|
|
|
} |
|
|
|
@ -396,7 +396,7 @@ splitsep() {
@@ -396,7 +396,7 @@ splitsep() {
|
|
|
|
|
while [ -n "$str" -a "$#" -gt 1 ]; do |
|
|
|
|
tmp="${str%%$sep*}" |
|
|
|
|
eval "$1='${tmp}'" |
|
|
|
|
str="${str#"$tmp"}" |
|
|
|
|
str="${str#$tmp}" |
|
|
|
|
str="${str#$sep}" |
|
|
|
|
shift |
|
|
|
|
done |
|
|
|
|