base/dracut-lib.sh: add trim()

trim() to remove leading and trailing whitespace

(cherry picked from commit ac422d577c)
master
Harald Hoyer 2016-06-10 14:31:52 +02:00
parent 0cf826a11a
commit 2949dcba29
1 changed files with 7 additions and 0 deletions

View File

@ -51,6 +51,13 @@ str_ends() {
[ "${1%*"$2"}" != "$1" ]
}

trim() {
local var="$*"
var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters
echo -n "$var"
}

if [ -z "$DRACUT_SYSTEMD" ]; then

warn() {