From 0bd9104a89603fdb7b5c449d530b593c792bf1cd Mon Sep 17 00:00:00 2001 From: alanw Date: Tue, 9 May 2023 14:34:15 -0700 Subject: [PATCH] modified trimmer --- functions | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/functions b/functions index 21b020a..869d028 100644 --- a/functions +++ b/functions @@ -554,7 +554,7 @@ chained-grep(){ # Remove leading/trailing whitespace trim() { - local var=$1 + local var=${@:2} var="${var#"${var%%[![:space:]]*}"}" var="${var%"${var##*[![:space:]]}"}" printf '%s' "$var" @@ -570,15 +570,17 @@ strip-html-tags() { run-from-url(){ url=$1 + # boxline "url=$url" args=${*:2} + # boxline "args=$args" # 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) - boxline "interpreter=$interpreter" + interpreter=$(curl -ks $url | head -n 1 | cut -c 2- 2>/dev/null) + # boxline "interpreter=$interpreter" # 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" + 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