While trying to process a list of file-/foldernames correctly (see my other questions) through the use of a NULL-character as a delimiter I stumbled over a strange behaviour
Use uuencode
and uudecode
for POSIX portability
xxd
and base64
are not POSIX 7 but uuencode is.
VAR="$(uuencode -m <(printf "a\0\n") /dev/stdout)"
uudecode -o /dev/stdout <(printf "$VAR") | od -tx1
Output:
0000000 61 00 0a
0000003
Unfortunately I don't see a POSIX 7 alternative for the Bash process <()
substitution extension except writing to file, and they are not installed in Ubuntu 12.04 by default (sharutils
package).
So I guess that the real answer is: don't use Bash for this, use Python or some other saner interpreted language.