0

Can someone tell me how to make the variable expand in the following, please:

MESSAGE="Public IP Address has changed"
osascript -e 'tell application (path to frontmost application as text) to display \ 
dialog "My message is ${MESSAGE} " buttons {"OK"} with icon stop'
1
  • Welcome on Stack Overflow! Would be great if you could explain your question a bit more by editing. Thanks! Commented Jun 18, 2018 at 16:58

1 Answer 1

1

The single quotes are preventing variable expansion: 3.1.2.2 Single Quotes

MESSAGE="Public IP Address has changed"
osascript -e 'tell application (path to frontmost application as text) to display \ 
dialog "My message is '"$MESSAGE"' " buttons {"OK"} with icon stop'
# ....................^^........^^

I'm using shell string concatenation there:

  • a single quote to close the first part of the single quoted string,
  • the variable expanded within double quotes,
  • a single quote to open the last part of the single quoted string.
Sign up to request clarification or add additional context in comments.

1 Comment

Also, you can't use line continuation (with an escaped newline) in the middle of a single-quoted string.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.