Ever write a script to see if you could do something, without considering whether you should?

Ok, so this has been eating at me, and still is. But here's what I think I've discovered.

  1. You didn't include a newline at the end of your sample.
  2. printf is not working as I expect it, and can discard the newline

#!/bin/bash

base64Mine='H4sIAAAAAAACAwvISU0sTlUozkgsSlVIzKtUKC1OzUktLlYoTi7KLCgpVshPU6jMLy1SyC/P0+MCAA4oKM0uAAAA'
base64Yours='H4sIAAAAAAACAwvISU0sTlUozkgsSlVIzKtUKC1OzUktLlYoTi7KLCgpVshPU6jMLy1SyC/P0+MCAA4oKM0uAAAA'
sameText="The variables are the same"
diffText="The variables are different"

text1=$(printf "%s" "${base64Mine}"  | base64 -d | gzip -d)
text2=$(printf "%s" "${base64Yours}" | base64 -d | gzip -d)

test "$(printf "%s" "${base64Mine}" | base64 -d | gzip -d) "  \
 = "$(printf "%s"  "${base64Yours}" | base64 -d | gzip -d)"   \
 && echo "${sameText}" \
 || echo "${diffText}"

test "$(printf "${base64Mine}" | base64 -d | gzip -d) "  \
 = "$(printf "${base64Yours}" | base64 -d | gzip -d)"   \
 && echo "${sameText}" \
 || echo "${diffText}"

test "$text1" = "$text2" && echo "${sameText}" || echo "${diffText}"
/r/bash Thread Parent