diff --git a/functions b/functions index 9c0d57c..8573200 100644 --- a/functions +++ b/functions @@ -538,6 +538,26 @@ clone-repo(){ run git clone --recurse-submodules $_url $_destination } +run-from-url(){ + url=$1 + args=${*:2} + # check the interpreter using the shebang at the top of the file + interpreter=$(curl -ks $url | head -n 1 | sed -e 's/\#\!//g' 2>/dev/null) + # In case of missing shebang, default to bash + if [ -z $interpreter ] ; then + interpreter="/bin/bash" + fi + logger boxline "Running online script $url with args $args" + if [[ "$interpreter" == "/bin/bash "]] ; then + run curl -H 'Cache-Control: no-cache' -ks $url | $interpreter -s -- $args + else + run curl -H 'Cache-Control: no-cache' -ks $url > ${url##*/} + run $interpreter ${url##*/} $args + ec=$? + run rm ${url##*/} + return $ec +} + ctrl_c(){ echo -e "\n" fail "User interrupted with Ctrl-C"