Merge pull request #1321 from bket/non-portable

'head -c BYTES' is non-portable.
dev
Nick Terrell 2018-09-17 14:40:27 -07:00 committed by GitHub
commit f884e9dd8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 4 deletions

View File

@ -48,6 +48,10 @@ fileRoundTripTest() {
$DIFF -q tmp.md5.1 tmp.md5.2 $DIFF -q tmp.md5.1 tmp.md5.2
} }
truncateLastByte() {
dd bs=1 count=$(($(wc -c < "$1") - 1)) if="$1" status=none
}
UNAME=$(uname) UNAME=$(uname)
isTerminal=false isTerminal=false
@ -592,7 +596,7 @@ if [ $GZIPMODE -eq 1 ]; then
$ZSTD -f --format=gzip tmp $ZSTD -f --format=gzip tmp
$ZSTD -f tmp $ZSTD -f tmp
cat tmp.gz tmp.zst tmp.gz tmp.zst | $ZSTD -d -f -o 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* rm tmp*
else else
$ECHO "gzip mode not supported" $ECHO "gzip mode not supported"
@ -659,8 +663,8 @@ if [ $LZMAMODE -eq 1 ]; then
$ZSTD -f --format=lzma tmp $ZSTD -f --format=lzma tmp
$ZSTD -f tmp $ZSTD -f tmp
cat tmp.xz tmp.lzma tmp.zst tmp.lzma tmp.xz tmp.zst | $ZSTD -d -f -o 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 !" truncateLastByte 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.lzma | $ZSTD -t > $INTOVOID && die "incomplete frame not detected !"
rm tmp* rm tmp*
else else
$ECHO "xz mode not supported" $ECHO "xz mode not supported"
@ -696,7 +700,7 @@ if [ $LZ4MODE -eq 1 ]; then
$ZSTD -f --format=lz4 tmp $ZSTD -f --format=lz4 tmp
$ZSTD -f tmp $ZSTD -f tmp
cat tmp.lz4 tmp.zst tmp.lz4 tmp.zst | $ZSTD -d -f -o 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* rm tmp*
else else
$ECHO "lz4 mode not supported" $ECHO "lz4 mode not supported"