1

Quite simply I have a shell script that I'm editing in XCode, and it contains several strings which contain new-lines. Easiest way for me to do this was just to leave the string open so that it spans several lines in the file, and as far as I know this is perfectly valid for a shell script to do, or at least none of the shells I work with seem to mind it.

However, XCode doesn't like it at all, and treats only the first line of the string as a string, and interprets the rest as new commands. This has no particular effect on the script, but is a huge pain as it looks messy, and causes it to try to auto-complete things that are part of the string. XCode only accepts it correctly if each line ends with an escape character, but of course that eliminates the new line so is of no use to me.

Here's a stripped down version of one of my strings:

#!/bin/sh
USAGE="$0 [options] source [host:]target
Arguments:
source
    Path to the folder or Time Machine .backupdb to backup from.
[host:]target
    Path to the target to backup to, with host for remote backup via ssh."

echo "$USAGE"

Putting this in XCode will cause only the first line of USAGE to be highlighted in red (string), while the rest are black. Is there a way to force XCode to interpret these multi-line strings, or is what I'm doing somehow wrong and I should be formatting my strings another, more compatible way?

1

I don't think that there is a way to get Xcode to highlight this the way you would like, so I tried a couple of my favorite text editors. BBEdit did not handle this correctly, but TextMate did.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .