dracut-functions.sh: add str_starts() and str_ends()

Harald Hoyer 2016-05-25 14:49:34 +02:00
parent 688afe0fc3
commit 6656e1547f
1 changed files with 4 additions and 0 deletions

View File

@ -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