Raw
1 # Library of git-cat-file related test functions.
2
3 # Print a string without a trailing newline.
4 echo_without_newline () {
5 printf '%s' "$*"
6 }
7
8 # Print a string without newlines and replace them with a NUL character (\0).
9 echo_without_newline_nul () {
10 echo_without_newline "$@" | tr '\n' '\0'
11 }
12
13 # Calculate the length of a string.
14 strlen () {
15 echo_without_newline "$1" | wc -c | sed -e 's/^ *//'
16 }