Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
osascript命令中的Bash expand变量_Bash - Fatal编程技术网

osascript命令中的Bash expand变量

osascript命令中的Bash expand变量,bash,Bash,有人能告诉我如何使变量在下面展开吗 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字符串连接: 单引号用于关闭单引号字

有人能告诉我如何使变量在下面展开吗

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字符串连接:

单引号用于关闭单引号字符串的第一部分, 变量在双引号内展开, 单引号打开单引号字符串的最后一部分。
欢迎使用堆栈溢出!如果你能通过编辑多解释一下你的问题,那就太好了。谢谢此外,在单个引用字符串的中间,不能使用带有转义换行符的行继续。
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'
# ....................^^........^^