#!/bin/bash

mkdir test
dd if=/dev/random of=test/file1.txt bs=1024 count=5 > /dev/null 2> /dev/null
cp test/file1.txt test/file2.txt
cp test/file1.txt test/file3.txt
cp test/file1.txt test/file4.txt
cp test/file1.txt test/file5.txt
cp test/file1.txt test/file6.txt
cp test/file1.txt test/file7.txt
mkdir test/subdir
cp test/file*txt test/subdir

zip -0 -q -r - test > f1
cat f1 | ditto -xk - .1

zip -0 -q -r - test | cat > f2
cat f2 | ditto -xk - .2

diff -r .1 .2 > /dev/null
if test $? != "0"; then echo "FAIL"; fi

ditto -xk f2 .3
diff -r .1 .3
if test $? != "0"; then echo "FAIL2"; fi

rm -rf f1 f2 .1 .2 .3 test
