712866
From ac422d577c1de1e94620787380932b9ccbd7b10a Mon Sep 17 00:00:00 2001
712866
From: Harald Hoyer <harald@redhat.com>
712866
Date: Fri, 10 Jun 2016 14:31:52 +0200
712866
Subject: [PATCH] base/dracut-lib.sh: add trim()
712866
712866
trim() to remove leading and trailing whitespace
712866
---
712866
 modules.d/99base/dracut-lib.sh | 7 +++++++
712866
 1 file changed, 7 insertions(+)
712866
712866
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
5c6c2a
index cb1ddd76..71dcedcf 100755
712866
--- a/modules.d/99base/dracut-lib.sh
712866
+++ b/modules.d/99base/dracut-lib.sh
712866
@@ -39,6 +39,13 @@ str_ends() {
712866
     [ "${1%*$2}" != "$1" ]
712866
 }
712866
 
712866
+trim() {
712866
+    local var="$*"
712866
+    var="${var#"${var%%[![:space:]]*}"}"   # remove leading whitespace characters
712866
+    var="${var%"${var##*[![:space:]]}"}"   # remove trailing whitespace characters
712866
+    echo -n "$var"
712866
+}
712866
+
712866
 if [ -z "$DRACUT_SYSTEMD" ]; then
712866
 
712866
     warn() {