#!/bin/sh

MSG() {
cat <<EOF

# This script 'unslp' extracts a Stampede.slp package.
#
# Kent Robotti 3-12-99
#
# USAGE: unslp -x -d directory package.slp   
# USAGE: unslp -l package.slp   <List contents of stampede.slp package>
#
# To use 'unslp' you need 'tar' and 'bzip2' on your system.  
#
# Extract stampede package to current directory.
# Example: unslp -x -d . package.slp
# Extract stampede package to a directory called fooboo, create
# the directory if it doesn't exist: # mkdir fooboo
# Example: unslp -x -d fooboo package.slp
# Extract stampede package to /mnt/linux directory.
# Example: unslp -x -d /mnt/linux package.slp

EOF
}

if [ "$1" = "" ]; then
MSG
exit
fi

if [ "$1" = "-x" -a "$2" = "-d" ]; then
if [ ! -d "$3" ]; then
echo "No such directory: $3"
exit 1
fi
tar xpvf $4 -C $3 --use-compress-program bzip2 2>/dev/null || exit 1  
echo
echo "$4 extracted to $3"
echo
exit 0
fi

if [ "$1" = "-l" -a -s "$2" ]; then
if [ ! "$PAGER" = "" ]; then
pager="$PAGER"
elif type -all less >/dev/null 2>&1 ; then
pager=less
elif type -all more >/dev/null 2>&1 ; then
pager=more
else
echo "No PAGER found, no more or less."
exit 1
fi
tar tvf $2 --use-compress-program bzip2 2>/dev/null | $pager
fi
