Blame SOURCES/0380-dracut-functions.sh-add-str_starts-and-str_ends.patch

a0a3b4
From 6656e1547f875253d1499bcd06ae0f6440a087c6 Mon Sep 17 00:00:00 2001
a0a3b4
From: Harald Hoyer <harald@redhat.com>
a0a3b4
Date: Wed, 25 May 2016 14:49:34 +0200
a0a3b4
Subject: [PATCH] dracut-functions.sh: add str_starts() and str_ends()
a0a3b4
a0a3b4
---
a0a3b4
 dracut-functions.sh | 4 ++++
a0a3b4
 1 file changed, 4 insertions(+)
a0a3b4
a0a3b4
diff --git a/dracut-functions.sh b/dracut-functions.sh
1755ca
index d71ff676..4a9729c7 100755
a0a3b4
--- a/dracut-functions.sh
a0a3b4
+++ b/dracut-functions.sh
a0a3b4
@@ -29,6 +29,10 @@ fi
a0a3b4
 
a0a3b4
 # Generic substring function.  If $2 is in $1, return 0.
a0a3b4
 strstr() { [[ $1 = *$2* ]]; }
a0a3b4
+# returns OK if $1 contains literal string $2 at the beginning, and isn't empty
a0a3b4
+str_starts() { [ "${1#"$2"*}" != "$1" ]; }
a0a3b4
+# returns OK if $1 contains literal string $2 at the end, and isn't empty
a0a3b4
+str_ends() { [ "${1%*"$2"}" != "$1" ]; }
a0a3b4
 
a0a3b4
 # helper function for check() in module-setup.sh
a0a3b4
 # to check for required installed binaries