#!/bin/bash
#
# List or extract files from .deb archives
#
# Copyright (c) 1998, Massimo Dal Zotto <dz@cs.unitn.it>
#
# This file is distributed under the GNU General Public License
# either version 2, or (at your option) any later version.

if [ $# -lt 2 ]; then
    echo "Usage: $0 <-t|-x> <archive> [<files...>]" >&2
    exit 1
fi

cmd="$1"
archive="$2"
shift 2

case ${cmd#-} in
    t|v)
        dpkg-deb --fsys-tarfile "$archive" | tar -tvf - "$@"
	;;
    x)
        dpkg-deb --fsys-tarfile "$archive" | tar -xf - "$@"
	;;
    *)
        echo "Unknown option: $cmd"
	;;
esac

# end of file
