]> git.plutz.net Git - clickslide/commitdiff
switch for base64 implementation
authorPaul Hänsch <paul@plutz.net>
Wed, 19 Jun 2019 03:12:18 +0000 (05:12 +0200)
committerPaul Hänsch <paul@plutz.net>
Wed, 19 Jun 2019 03:12:18 +0000 (05:12 +0200)
clickslide.sh

index e78f1c7a30c5568454bd1a8e28d3f1b0f816a4f6..291130a35ba128217c205033a571cae8cb58a6e1 100755 (executable)
@@ -3,9 +3,13 @@
 prev='' next='' idoff=0
 depth=0 ucdepth=-1
 
-base64() {
-  uuencode -m - <"$1" \
-  | sed '1d; :X;$!{N;bX;}; s;\n;;g; s;=\+;;g;'
+_base64() {
+  { uuencode -m - <"$1" \
+    | sed '1d; :X;$!{N;bX;}; s;\n;;g; s;=\+;;g;'
+  } || {
+    base64 <"$1" \
+    | sed ':X;$!{N;bX;}; s;\n;;g; s;=\+;;g;'
+  }
 }
 
 { "${0%/*}"/cgilite/html-sh.sed || cat; } \
@@ -36,7 +40,7 @@ base64() {
       file="${file#\"}" file="${file%\"}"
       echo Inlining Background Image "$file" >&2
       if [ -r "$file" ]; then
-        tag="${pre}url('data:image/${file##*.};base64,$(base64 "$file")')${post}"
+        tag="${pre}url('data:image/${file##*.};base64,$(_base64 "$file")')${post}"
       fi
     done >/dev/null
 
@@ -47,7 +51,7 @@ base64() {
       file="${tag#${pre}src=\"}" file="${file%\"$post}"
       echo Inlining Image "$file" >&2
       if [ -r "$file" ]; then
-        tag="${pre}src=\"data:image/${file##*.};base64,$(base64 "${file}")\"${post}"
+        tag="${pre}src=\"data:image/${file##*.};base64,$(_base64 "${file}")\"${post}"
       fi
     done >/dev/null