Skip to content

Instantly share code, notes, and snippets.

@slumos
Created April 19, 2011 17:08
Show Gist options
  • Select an option

  • Save slumos/928857 to your computer and use it in GitHub Desktop.

Select an option

Save slumos/928857 to your computer and use it in GitHub Desktop.
#! /bin/sh
# fetch - figure out how to get some url and do it
find_prog () {
prog=$1
ret=1
OIFS=$IFS
IFS=:
for d in $PATH; do
if test -f $d/$prog && test -x $d/$prog; then
ret=0
break
fi
done
IFS=$OIFS
return $ret
}
if [ "$#" -ne 1 -o "$1" = "-h" ]; then
name="`basename $0`"
echo "usage: $name url" 1>&2
exit 127
fi
url="$1"
if find_prog curl; then
curl -OL "$url"
elif test -f /usr/pkg/bin/ftp; then
ftp "$url"
elif find_prog wget; then
wget "$url"
elif find_prog lwp-download; then
lwp-download "$url"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment