#!/bin/bash

# Written by Joseph Clancy (jclancy@wimsey.com).
# Copyright (c) 1996, and placed under the GPL; see COPYING for further info.

echo snag-o-rama v1.4 by Joseph Clancy

if [ -z "$1" ]; then
  echo "Usage: "
  echo "snag http://host/path/file.html [verbose] [noimages] [chaseparents]" 
  exit
fi

if [ -f "index.html.real" ]; then
  echo "Gee... looks like index.html.real already exists."
  echo "You should probably start snag in an empty directory."
  exit
fi

URL=$1
export URL
snagit "$1" index.html $$.run 0 $2 $3 $4 $5 $6
if [ ! -f "$$.run" ]; then
  echo "Hmmm... $$.run wasn't created; snag probably couldn't retreive your URL"
  exit
fi

chmod +x $$.run 
if [ -f "$$.run" ]; then
  ./$$.run
fi

if [ ! -f "$$.run.error" ]; then
  rm $$.run
else
  echo "There were errors; see $$.run.error for affected URLs"
fi


