#!/bin/bash
# core/str - Bash Script String Support
set -e
######
# String Support
# 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 Tue Jul 4 17:00:26 PDT 2017 by mcsh d14 v0.21.0.