This is a problem that I've had for a while, and it pops up especially in combination with ssh. I don't quite understand how to begin tackling it. EDIT: Use explicit quoting. An approximate implementation isn't that hard. See ecat.erl A correct implementation probably needs to re-implement %q for /usr/bin/printf.