有人可以告诉我如何在以下内容中扩展变量,请:
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'
答案 0 :(得分:1)
单引号阻止了变量扩展: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'
# ....................^^........^^
我在那里使用shell字符串连接: