From 06fd1e473d2435b3a58741a8cfca802fbf4aa5a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ketelaars?= Date: Sat, 30 Jun 2018 15:42:42 +0200 Subject: [PATCH] 'head -c BYTES' is non-portable. tests/playTests.sh uses 'head -c' in a couple of tests to truncate the last byte of a file. The '-c' option is non-portable (not in POSIX). Instead use a wrapper around dd (truncateLastByte). --- tests/playTests.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/playTests.sh b/tests/playTests.sh index fa0685c6..19b50299 100755 --- a/tests/playTests.sh +++ b/tests/playTests.sh @@ -48,6 +48,10 @@ fileRoundTripTest() { $DIFF -q tmp.md5.1 tmp.md5.2 } +truncateLastByte() { + dd bs=1 count=$(($(wc -c < "$1") - 1)) if="$1" status=none +} + UNAME=$(uname) isTerminal=false @@ -592,7 +596,7 @@ if [ $GZIPMODE -eq 1 ]; then $ZSTD -f --format=gzip tmp $ZSTD -f tmp cat tmp.gz tmp.zst tmp.gz tmp.zst | $ZSTD -d -f -o tmp - head -c -1 tmp.gz | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !" + truncateLastByte tmp.gz | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !" rm tmp* else $ECHO "gzip mode not supported" @@ -659,8 +663,8 @@ if [ $LZMAMODE -eq 1 ]; then $ZSTD -f --format=lzma tmp $ZSTD -f tmp cat tmp.xz tmp.lzma tmp.zst tmp.lzma tmp.xz tmp.zst | $ZSTD -d -f -o tmp - head -c -1 tmp.xz | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !" - head -c -1 tmp.lzma | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !" + truncateLastByte tmp.xz | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !" + truncateLastByte tmp.lzma | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !" rm tmp* else $ECHO "xz mode not supported" @@ -696,7 +700,7 @@ if [ $LZ4MODE -eq 1 ]; then $ZSTD -f --format=lz4 tmp $ZSTD -f tmp cat tmp.lz4 tmp.zst tmp.lz4 tmp.zst | $ZSTD -d -f -o tmp - head -c -1 tmp.lz4 | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !" + truncateLastByte tmp.lz4 | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !" rm tmp* else $ECHO "lz4 mode not supported"