]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
dracut-functions.sh: add str_starts() and str_ends()
authorHarald Hoyer <harald@redhat.com>
Wed, 25 May 2016 12:49:34 +0000 (14:49 +0200)
committerHarald Hoyer <harald@redhat.com>
Wed, 25 May 2016 12:49:34 +0000 (14:49 +0200)
dracut-functions.sh

index d71ff67683d112e33ac78da04d0492760023efed..4a9729c772c6646aca9440170a4e8446ccb9619d 100755 (executable)
@@ -29,6 +29,10 @@ fi
 
 # Generic substring function.  If $2 is in $1, return 0.
 strstr() { [[ $1 = *$2* ]]; }
+# returns OK if $1 contains literal string $2 at the beginning, and isn't empty
+str_starts() { [ "${1#"$2"*}" != "$1" ]; }
+# returns OK if $1 contains literal string $2 at the end, and isn't empty
+str_ends() { [ "${1%*"$2"}" != "$1" ]; }
 
 # helper function for check() in module-setup.sh
 # to check for required installed binaries