-
Notifications
You must be signed in to change notification settings - Fork 0
/
importablesh.sh
37 lines (28 loc) · 935 Bytes
/
importablesh.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# to be imported
# This is the bootstrapper of importablesh
# The newest version is available at https://raw.githubusercontent.com/wipu/importablesh/master/importablesh.sh
# Released under the MIT license
set -euo pipefail
IMPORTABLESH_VER=98af6c2d9e6f90327f13e49d2f8d086564253720
IMPORTABLESH_ZIP_URL=https://github.com/wipu/importablesh/archive/$IMPORTABLESH_VER.zip
IMPORTABLESH_USERDIR=$(readlink -f "$(dirname "$BASH_SOURCE")")
export CACHED=$IMPORTABLESH_USERDIR/cached
mkdir -p "$CACHED"
get-url-to() {
local FROM=$1
local TO=$2
type wget &>/dev/null && {
wget "$FROM" -O "$TO"
} || {
curl -L "$FROM" -o "$TO"
}
}
ensure-importablesh() {
local DEST=$CACHED/importablesh-$IMPORTABLESH_VER
export IMPORTABLESH=$DEST
[ -e "$DEST" ] && return
get-url-to "$IMPORTABLESH_ZIP_URL" "$DEST".zip
unzip "$DEST".zip -d "$CACHED"
}
ensure-importablesh
. "$IMPORTABLESH"/functions/import.sh