X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=lib%2Ftools.in;fp=lib%2Ftools.in;h=4ca438f05e8dc17fc7d44537e66145609a0d1dc4;hb=1f3891846c79f57c458e6848958f4f5c5cd08898;hp=b180950789c60ead1def01525e69dca8c78279e2;hpb=ac915b2a77c0bcbcacc8b07042c7d3d2eeebb79a;p=matthijs%2Fupstream%2Fbackupninja-vserver.git diff --git a/lib/tools.in b/lib/tools.in index b180950..4ca438f 100644 --- a/lib/tools.in +++ b/lib/tools.in @@ -97,3 +97,11 @@ function starts_with() { # Is it equal to $2? [ "$head" = "$2" ] } + +# Strip the prefix $2 from $1. Assumes that $1 actually starts with $1. +# The result is put on stdout. +function strip_prefix() { + # Strip the first ${#2} (the length of $2) characters from $1. + # tail -c +N means start at the Nth byte, 1-based, so we add 1. + echo $1 | tail -c +$((${#2}+1)) +}