#!/bin/sh # emulate-gnu-tar -- emulate the options of GNU tar that librep uses # in its tar-file handling code. # $Id: emulate-gnu-tar,v 1.1 2001/03/13 00:51:06 jsh Exp $ compression_mode="" command="" tarfile="" to_stdout="" version="1.0" original_directory=`pwd` usage () { cat <&2 exit 1 ;; esac shift done if [ "x$command" = x ]; then usage exit 1 fi case "$compression_mode" in gzip) input="gzip -d -c \"$tarfile\" |" ;; compress) input="compress -d -c \"$tarfile\" |" ;; bzip2) input="bzip2 -d -c \"$tarfile\" |" ;; *) input="cat \"$tarfile\" |" ;; esac case "$command" in list) eval "$input tar tvf -" ;; extract) if [ "x$to_stdout" = "x" ]; then eval "$input tar xf -" exit $? else # Extract the file to a temporary directory, then cat it.. tmpdir="/tmp/rep-emulate-gnu-tar.$$.output" mkdir "$tmpdir" || exit $? cd "$tmpdir" eval "$input tar xf - $to_stdout" || ( rm -rf $tmpdir && exit $? ) cat "$to_stdout" cd "$original_directory" rm -rf "$tmpdir" exit 0 fi ;; *) echo "Unimplemented command: $command" exit 1 ;; esac