Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Well, it grows exponentially.

You want to end up with one backslash `\`. After one escape, you get `\\`. If you escape the escaped string, you get `\\\\`. After another layer, you get `\\\\\\\\` for a single backslash.

Here's a somewhat realistic example: You need a piece of javascript in a string literal, and you need that javascript to generate a regex matcher for a single backslash. You could do that like this:

let code = "new RegExp(\"\\\\\\\\\")";

It's not _that_ uncommon when you need to marshal one language through many layers of languages (in my example, the regex language being marshalled through a javascript string literal and then another layer of javascript string literal). In XCode's case, two layers are obvious; you want a backslash, so you need the string which is fed to the shell to contain `\\`, so your XCode string literal has to be `"\\\\"`. For some unknown reason, there's a third level of escapes which takes us to `"\\\\\\\\"`.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: