summaryrefslogtreecommitdiff
path: root/t/lib-cat-file.sh
blob: 7c2e8770164ce344f0cfcde1dd1913d40d00cd30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Library of git-cat-file related test functions.

# Print a string without a trailing newline.
echo_without_newline () {
	printf '%s' "$*"
}

# Print a string without newlines and replace them with a NUL character (\0).
echo_without_newline_nul () {
	echo_without_newline "$@" | tr '\n' '\0'
}

# Calculate the length of a string.
strlen () {
	echo_without_newline "$1" | wc -c | sed -e 's/^ *//'
}