Blame SOURCES/0386-base-dracut-lib.sh-add-trim.patch

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