From 0c1d593673ca67d46204402acddbbfb5e568f277 Mon Sep 17 00:00:00 2001 From: alanw Date: Tue, 20 Jun 2023 14:08:28 -0700 Subject: [PATCH] added additional failovers and checks to run-from-url() --- functions | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/functions b/functions index eeddb4a..3297182 100644 --- a/functions +++ b/functions @@ -587,15 +587,39 @@ run-from-url(){ # check the interpreter using the shebang at the top of the file interpreter=$(curl -ks $url | head -n 1 | sed -n -e 's\/\#//g' 2>/dev/null) # boxline "interpreter=$interpreter" + # In case of missing shebang, default to local shells # In case of missing shebang, default to bash + # In case of missing shebang, default to local shells if [ -z $interpreter ] ; then + if [ -x /bin/bash ] ; then + if [ -x /bin/bash ] ; then + interpreter="/bin/bash" interpreter="/bin/bash" + interpreter="/bin/bash" + elif [ -x /bin/sh ] ; then + interpreter="/bin/sh" + elif [ -x /bin/zsh ] ; then + interpreter="/bin/zsh" + elif [ -x /bin/sh ] ; then + interpreter="/bin/sh" + elif [ -x /bin/zsh ] ; then + interpreter="/bin/zsh" + fi fi + fi + fi + logger boxline "Running online script $url with args $args" boxline "Running online script $url with args $args" + fi + logger boxline "Running online script $url with args $args" if [[ "$interpreter" == "/bin/bash" ]] ; then + run curl -H 'Cache-Control: no-cache' -kLs $url | $interpreter -s -- $args run curl -H 'Cache-Control: no-cache' -ks $url | $interpreter -s -- $args + run curl -H 'Cache-Control: no-cache' -kLs $url | $interpreter -s -- $args else + run curl -H 'Cache-Control: no-cache' -kLs $url > ${url##*/} run curl -H 'Cache-Control: no-cache' -ks $url > ${url##*/} + run curl -H 'Cache-Control: no-cache' -kLs $url > ${url##*/} run $interpreter ${url##*/} $args ec=$? run rm ${url##*/}