Here is example code that I need to submit via osascript:
osascript -e ‘set AppleScript’s text item delimiters to “:”’
However, the apostrophe in “AppleScript’s” messes up osascript.
I can write:
osascript -e ‘set AppleScript’\’‘s text item delimiters to “:”’
However, AppleScript will now baulk at the apostrophe backslash apostrophe apostrophe ‘’’ while trying to compile it without osascript.
Is there a way to encode the apostrophe, like a hex code \x27 or something else, that will allow both Applescript and osascript to compile?
PS. I know I can remove “Applescript’s” from “text item delimiters” and get the same result. My problem is more involved and I didn’t want to place all the code here. Just an example to present my problem.
I’m wondering where you’re getting the text with the smart quotes (AKA curly, typographer’s quotes)? Script Debugger, by default, uses dumb quotes (straight quotes).
Some applications allow an option-’ to force a straight quote.
#!/usr/bin/env bash
read -r -d '' dataStr <<'EOF'
set dataStr to "Now is the time for all good men to come to the aid of their country."
set AppleScript's text item delimiters to " "
return text items of dataStr
EOF
osascript -e "$dataStr"