projects
/
matthijs
/
upstream
/
backupninja.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
9341c14
)
Add starts_with function.
author
Matthijs Kooijman
<matthijs@stdin.nl>
Wed, 7 Jan 2009 20:56:18 +0000
(21:56 +0100)
committer
Matthijs Kooijman
<matthijs@stdin.nl>
Wed, 7 Jan 2009 20:56:18 +0000
(21:56 +0100)
This function compares two strings (paths) and checks if the first
starts with the second (the first path lies within the second).
lib/tools.in
patch
|
blob
|
history
diff --git
a/lib/tools.in
b/lib/tools.in
index fe7d54a38de94fc8c7b44513e402e227314021d8..b180950789c60ead1def01525e69dca8c78279e2 100644
(file)
--- a/
lib/tools.in
+++ b/
lib/tools.in
@@
-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" ]
+}