#!/bin/bash
# core/str - Bash Script String Support
set -e
######
# String Support
# str_split() - Splits the strings ($@) by the given character ($1).
str_split() {
local IFS=$1
shift
echo $*
}
# str_here_var() - Reads standard input into the named variable ($1).
# $1 - Name of variable to receive ``stdin`` as a string.
str_here_var() { read -r -d '' $1; }
# str_trim() - Trims whitespaces from start and end of a string ($1).
str_trim() {
local str=$1
shopt -s extglob
str=${1%%+([[:space:]])}
str=${1##+([[:space:]])}
shopt -u extglob
echo "$str"
}
# str_endswith() - Returns success if a string ($1) ends with
# another string ($2).
str_endswith() { [ "${1%$2}" != "$1" ]; }
# str_startswith() - Returns success if a string ($1) start with
# another string ($2).
str_startswith() { [ "${1#$2}" != "$1" ]; }
Generated on Fri Jul 28 14:35:05 PDT 2017 by mcsh d14 v0.23.0.