#!/bin/sh type=$1 shift dir=`mktemp -d` cd $dir # Prepare test archive (hope paths will not be mangled). # Assume that `mktemp` creates files in /tmp/ . ln -s /tmp dir abs=`mktemp` rel=`mktemp` link=`mktemp` if [ "$type" = cpio ]; then echo "\ $abs ../`basename $rel` dir dir/`basename $link`" | cpio -o > arc 2> /dev/null else tar -cPf arc $abs ../`basename $rel` dir dir/`basename $link` fi rm $abs $rel dir $link # Extract if [ "$type" = cpio ]; then "$@" < arc else "$@" -f arc fi 2> /dev/null for file in $abs $rel $link; do if [ -f "$file" ]; then printf -- "x " rm "$file" else printf -- "= " fi done echo "$@" cd - > /dev/null rm -r $dir