If you check with wc
, you will find that the NUL character is actually passed:
$ python -c 'print "\x00"' | wc -c 2
To get rid of a new line at the end:
$ python -c 'import sys; sys.stdout.write("\x00")' | wc -c 1
This data is passed to the script, but the problem is that NUL cannot be part of the variable value.
To find out how to do this, try passing this script:
$ cat test.sh #!/usr/bin/env bash echo ${#1} $ ./test.sh "$(python -c 'import sys; sys.stdout.write("\x00")')" 0
Gone But there is a way to save the day - read from standard input using either a redirect or a channel:
$ cat test2.sh
source share