1# $OpenBSD: t5.sh,v 1.1 2006/01/25 17:42:08 markus Exp $
2# append without a file list should not corrupt a tar file
3#
4OBJ=$2
5cd ${OBJ}
6fail () {
7	rm -f a b foo.tar
8	echo "$*"
9	exit 1
10}
11echo a > a
12echo b > b
13echo a  | pax -w -f foo.tar
14tar tf foo.tar | grep -q a || fail missing file a
15# append without a file list
16echo -n | pax -w -a -f foo.tar
17tar tf foo.tar > /dev/null || fail not a tar file
18# again
19echo    | pax -w -a -f foo.tar
20tar tf foo.tar > /dev/null || fail not a tar file
21# append file
22echo b  | pax -w -a -f foo.tar
23for i in a b; do
24	tar tf foo.tar | grep -q $i || fail missing file $i
25done
26rm -f a b foo.tar
27