]> git.ipfire.org Git - thirdparty/dracut.git/blobdiff - dracut-functions.sh
fix(zipl): remove trailing spaces from zipl boot device name
[thirdparty/dracut.git] / dracut-functions.sh
index 6ab31aa87182c52a1c7f0216b7592b6131933e85..280e4e782373d94bf81d01b32ef20becbd2d9089 100755 (executable)
@@ -37,6 +37,13 @@ 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" ]; }
 
+trim() {
+    local var="$*"
+    var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
+    var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters
+    printf "%s" "$var"
+}
+
 # find a binary.  If we were not passed the full path directly,
 # search in the usual places to find the binary.
 find_binary() {