on unix the easiest way to quote is single quotes; something like this:

```
 "'" + x.replaceAllLiterally("'", """'\''""") + "'"
```

i.e. put all single quotes outside of single quotes and backslash them, single quote everything else. Double quotes are hard to get right because they support backslash escapes and `$VARIABLE`s.

On Windows, who knows. I guess we have been just adding double quotes so far.