Applescript似乎没有正确地逃避字符串.我究竟做错了什么?
例:
@H_404_3@set abc to "funky-!@#'#\"chars" display dialog abc display dialog quoted form of abc预期/期望的产出:
@H_404_3@funky-!@#'#"chars 'funky-!@#\'#"chars'实际产量:
@H_404_3@funky-!@#'#"chars 'funky-!@#'\''#"chars'正如您所看到的,似乎在实际输出中Applescript正在添加并转发额外的’
我会很好,结尾字符是“或”,我也可以将单引号和双引号转义 – 但看起来只有单引号实际上是转义的.
反斜杠通常不会在shell中的单引号内解释.
Enclosing characters in single quotation marks preserves the literal value of each character within the single quotation marks. A single quotation mark cannot occur within single quotation marks.
A backslash cannot be used to escape a single quotation mark in a string that is set in single quotation marks. An embedded quotation mark can be created by writing,for example: ‘a’\”b’,which yields a’b.
然而,它们由echo in sh解释,这是do shell脚本使用的shell:
@H_404_3@do shell script "echo " & quoted form of "\\t" --> "\t"取消设置xpg_echo使其行为类似于bash中的echo:
@H_404_3@do shell script "shopt -u xpg_echo; echo " & quoted form of "\\t" --> "\\t"通常使用HEREDOC重定向更简单:
@H_404_3@do shell script "rev <<< " & quoted form of "a\\tb" --> "b\\ta"