#!/usr/bin/env bash
# runner 1.4.1
# Run scripts hosted remotely, executing the latest version locally

set -euo pipefail  # Fail immediately on any error
Gre='\e[1;32m' Red='\e[1;31m' Mag='\e[1;35m' Yel='\e[1;33m' Blu='\e[1;34m' Rst='\e[0m'

# Set up a temp directory, to be deleted at exit
TempDir=$(mktemp -d); trap 'rm -rf "${TempDir}"' EXIT

# Download and execute the remote script. Note that the name of
# this local runner script determines the remote script to fetch
Script="$(basename $0)"
curl -kso "${TempDir}/${Script}" "https://que.one/scripts/${Script}"
chmod +x "${TempDir}/${Script}"
"${TempDir}/${Script}" "$@"
exit 0
