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

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