Automator AppleScript - 试图将字符串变量回显到 Bash

Automator AppleScript - trying to echo a string variable to Bash

我正在尝试使用 Automator 创建服务。

在 运行 AppleScript 动作中,我有一个变量,它是一个字符串,其中每一行都是一个由换行符分隔的单词。像这样:

à
às
a
ante
ao
aos
após
aquela

当我尝试通过以下方式将其回显到终端时:

do shell script "echo " & (finalText as string)

我收到这个错误:

The action “Run AppleScript” encountered an error: “sh: line 1: a: command not found
sh: line 2: à: command not found
sh: line 3: ante: command not found
...
sh: -c: line 30: syntax error near unexpected token `do'
sh: -c: line 30: `do'”

有什么想法吗?

为了摆脱 command not found 在这种情况下的类型错误,几乎在任何时候将 variable 传递给 do shell script 命令, 使用:

do shell script "echo " & finalText's quoted form

您还可以使用:

do shell script "echo " & quoted form of finalText

看你喜欢哪个合适。