get
References curl flags and HTTP URLShell command-substitution syntax
SHA-2569cc286f56369b7251cbd48edcd11802fc4085b3d10cd402995b0d1f47a089333
MaleculeK(Am)H₆(Cm₁₂Db₃FOs₃Po₃U)Md(Pt₂)
Evidence
1#!/bin/bash
2# Usage: curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s <HUB_VERSION>
3#
4# Downloads the hub binary into `bin/hub` within the current directory.
5
6set -e
7
8latest-version() {
9 curl -fsi https://github.com/github/hub/releases/latest | awk -F/ '/^Location:/ {print $(NF)}'
10}
11
12HUB_VERSION="${1#v}"
13if [ -z "$HUB_VERSION" ]; then
14 latest=$(latest-version) || true
15 [ -n "$latest" ] || latest="v2.14.1"
16 cat <<MSG >&2
17Error: You must specify a version of hub via the first argument. Example:
18 curl -L <script> | bash -s ${latest#v}
19MSG
20 exit 1
21fi
22
23ARCH="amd64"
24OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
25[[ $OS != mingw* ]] || OS="windows"
26
27download() {
28 if [ "$OS" = windows ]; then
29 zip="${1%.tgz}.zip"
30 curl -fsSLO "$zip"
31 unzip "$(basename "$zip")" bin/hub.exe
32 rm -f "$zip"
33 elif [ "$OS" = darwin ]; then
34 curl -fsSL "$1" | tar xz --strip-components=1 '*/bin/hub'
35 else
36 curl -fsSL "$1" | tar xz --strip-components=1 --wildcards '*/bin/hub'
37 fi
38}
39
40download "https://github.com/github/hub/releases/download/v$HUB_VERSION/hub-$OS-$ARCH-$HUB_VERSION.tgz"
41
42bin/hub version
43if [ -z "$GITHUB_TOKEN" ]; then
44 cat <<MSG >&2
45Warning: We recommend supplying the GITHUB_TOKEN environment variable to avoid
46being prompted for authentication.
47MSG
48fi