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

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