Is there a binary-safe "triple less than" <<< operator in bash?
Solution 1:
The here string redirection (<<<
) is a simple form of here document redirection (<<
). Here string redirection is not "binary safe"; Bash will perform expansion on the here string. In addition, Bash will append a new-line to the end of the here string (issue the command xxd -p <<< "foo"
and you'll get 666f6f0a
in return).
Your only safe bet, excluding pipes, is I/O redirection.
Similar not binary safe question here. You can store encoded data and try this
COMMAND_WITH_BIN_INPUT <(uudecode <(echo "$uuEncodedData"))
however this is not far from
echo "$uuEncodedData"|uudecode|COMMAND_WITH_BIN_INPUT
but without pipe metachar.
Solution 2:
Bash isn't binary safe in general, and will corrupt nulls and newlines in variables containing binary content during substitution.
So I think the answer is "no" but more fundamentally "not in a shell scripting language" because they all seem to have problems with binary.
I'd say however you plan to get the data into $GIF, you instead get it into a file, or use python as an alternative scripting language which will handle binary data without problems.