fetch.sh 844 Bytes
Newer Older
1 2
#!/bin/sh

Jordan Sissel's avatar
Jordan Sissel committed
3
echo "$@"
4
set -- `getopt o: "$@"`
Jordan Sissel's avatar
Jordan Sissel committed
5
echo "$@"
6 7 8 9 10 11 12

while [ $# -gt 0 ] ; do
  case "$1" in
    -o)
      OUTPUT=$2
      shift
      ;;
Jordan Sissel's avatar
Jordan Sissel committed
13 14 15 16
    --) 
      shift
      break
      ;;
17
  esac
Jordan Sissel's avatar
Jordan Sissel committed
18

19 20 21 22
  shift
done

URL="$1"
Jordan Sissel's avatar
Jordan Sissel committed
23
echo "URL: $URL"
24

25 26
# If you need to pass any specific flags to any specific fetcher, set
# WGET_FLAGS, CURL_FLAGS, or GET_FLAGS in your environment accordingly.
27
if which wget > /dev/null 2>&1 ; then
28 29 30 31
  # Check if wget is a shitty version
  if ! wget -O /dev/null -q https://github.com/ ; then
    WGET_FLAGS="${WGET_FLAGS} --no-check-certificate"
  fi
32
  exec wget $WGET_FLAGS -O "$OUTPUT" "$URL"
33
elif which curl > /dev/null 2>&1 ; then
34
  exec curl $CURL_FLAGS -s -o "$OUTPUT" "$URL"
Jordan Sissel's avatar
Jordan Sissel committed
35
elif which GET > /dev/null 2>&1 ; then
36
  exec GET $GET_FLAGS "$URL" > "$OUTPUT"
37 38 39 40 41
else
  echo "no http download tool found. cannot fetch."
  exit 1
fi