#!/usr/bin/env bash #get.bpkg.sh: bpkg(1) installer Contribute on GitHub

## get.bpkg.sh

Use this self hosted script to install the bpkg(1) bash package manager.

### USAGE

curl -Lo- get.bpkg.sh/1.0.13 | bash

### CODE


##
# `bpkg(1)` installer script that fetches the canonical `setup.sh` script and runs it
# in the calling context.
##

declare GIT_REMOTE=${GIT_REMOTE:-"https://raw.githubusercontent.com"}
declare GIT_BRANCH=${GIT_BRANCH:-"1.0.13"}
declare SETUP_URL=${SETUP_URL:-""}

if [ -z "$SETUP_URL" ]; then
  if [ -n "$GIT_BRANCH_EMPTY" ]; then
    declare SETUP_URL="$GIT_REMOTE/bpkg/bpkg/setup.sh"
  else
    declare SETUP_URL="$GIT_REMOTE/bpkg/bpkg/$GIT_BRANCH/setup.sh"
  fi
fi

if which curl >/dev/null 2>&1; then
  curl -Lo- "$@" "$SETUP_URL" | bash
elif which wget >/dev/null 2>&1; then
  wget -O - "$SETUP_URL" "$@" | bash
elif which aria2c >/dev/null 2>&1; then
  if aria2c -o bpkg-setup.sh "$SETUP_URL"  "$@"; then
    bash bpkg-setup.sh
  fi
elif [ -x "$REQUEST_FALLBACK_COMMAND" ]; then
  "$REQUEST_FALLBACK_COMMAND" "$@" "$SETUP_URL"
else
  echo >&2 "error: Could not fetch '$SETUP_URL'"
  exit 1
fi

exit $?

## See https://github.com/bpkg/bpkg for more information about the bpkg(1) command line tool. 

### TAGS