You can try to have ./script.py
output a non-breaking space (U+00a0) instead of a regular space, which bash
will not use for word-splitting. However, I would file a bug report to have the script that calls main
add quotes to its argument. Whether this works depends on how main
reacts to getting a string that consists of a two-byte UTF-8 sequence representing U+00a0 rather than a single space character.
A sample script.py
:
#!/usr/bin/python
print u'foo\xa0bar'.encode('utf8')
A sample script a.bash
:
#!/bin/bash
main () {
echo $#
}
main $(script.py)
And finally, a demonstration that main
gets 1 argument from the output of script.py
:
$ bash a.bash
1