Add starts_with function.
[matthijs/upstream/backupninja.git] / lib / tools.in
index fe7d54a38de94fc8c7b44513e402e227314021d8..b180950789c60ead1def01525e69dca8c78279e2 100644 (file)
@@ -89,3 +89,11 @@ function interpolate() {
        # Do the actual interpolation
        echo $path | sed "$expr"
 }
+
+# Does the $1 start with $2 ?
+function starts_with() {
+       # Get the head of $1 as long as $2
+       head=`echo $1 | head -c ${#2}`
+       # Is it equal to $2?
+       [ "$head" = "$2" ]
+}