Search code examples
terminalapplescriptosascript

Terminal Applescript unable to escape quote


I've run into a strange problem when trying to include quote marks ' ' in my osascript command.

If I try and escape a normal escapable character, it works fine. Example: osascript -e 'tell app "Finder" to display dialog "Te\\st"' A dialog box from Finder pops up with the text Test in it.

However, the problem occurs when I try and use apostrophes when I'm writing out full sentences. Example: osascript -e 'tell app "Finder" to display dialog "Te\'st"' When I run this, all I'm left with is no dialog box, and the text input in terminal looking like this:

>

From what I know, this should by all means work, however, it doesn't.


Solution

  • You can do it this way:

    osascript -e "tell app \"Finder\" to display dialog \"'Something' in quotes"\"