{
  \unalias command
  \unset -f command
} >/dev/null 2>&1

die() {
  if [ -e /dev/stderr ]; then
    printf "\033[31m%s\033[m\n\r" "$*" >/dev/stderr
  elif [ -e /dev/fd/2 ]; then
    printf "\033[31m%s\033[m\n\r" "$*" >/dev/fd/2
  else
    printf "\033[31m%s\033[m\n\r" "$*"
  fi
  exit 1
}

if command -v curl 2>/dev/null >/dev/null; then
  fetch() {
    command curl -fL "$1"
  }
  fetch_quiet() {
    command curl -fsSL "$1"
  }
elif command -v wget 2>/dev/null >/dev/null; then
  fetch() {
    command wget -O- "$1"
  }
  fetch_quiet() {
    command wget --quiet -O- "$1"
  }
else
  die "Neither curl nor wget available, can not download..."
fi
