From 6656e1547f875253d1499bcd06ae0f6440a087c6 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Wed, 25 May 2016 14:49:34 +0200 Subject: [PATCH] dracut-functions.sh: add str_starts() and str_ends() --- dracut-functions.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dracut-functions.sh b/dracut-functions.sh index d71ff676..4a9729c7 100755 --- a/dracut-functions.sh +++ b/dracut-functions.sh @@ -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