wip
This commit is contained in:
parent
dd4e4cabf1
commit
085860819d
2 changed files with 248 additions and 0 deletions
27
script-import.sh
Normal file
27
script-import.sh
Normal file
|
@ -0,0 +1,27 @@
|
|||
# ex: source-script "https://url/to/script.sh"
|
||||
source-script() {
|
||||
local url="$1"
|
||||
local import="$(mktemp)"
|
||||
|
||||
# ─< if $1 is a local file, source this one instead >─────────────────────────────────────
|
||||
if [ -f "$url" ]; then
|
||||
source "$url"
|
||||
sleep 0.1
|
||||
return 0
|
||||
else
|
||||
echo_info "Sourcing external script:${NC} $url"
|
||||
# ─< if $1 is a url, grab it and source it, also deletes afterwards >─────────────────────
|
||||
if command_exists curl; then
|
||||
curl -fsSL $url -o $import
|
||||
elif command_exists wget; then
|
||||
wget -O $import $url
|
||||
else
|
||||
echo "curl/wget is required, but missing.."
|
||||
exit 69
|
||||
fi
|
||||
|
||||
source "$import"
|
||||
sleep 0.1
|
||||
rm -f "$import"
|
||||
fi
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue