【发布时间】:2015-11-23 20:16:59
【问题描述】:
我正在尝试在 OS X 上创建一个自动化工作流程,它会在查找器中打开所选图像并使用 Photoshop 打开它
在此期间,我需要使用 Shell,这是我的代码
# create an empty string
a=""
# grab all the files selected in the finder (given by the previous operation)
for f in "$@"
do
# make a concatenation of the strings
a=$a" $f"
done
# change the spaces " " by backslash+space "\ "
a=${a//$" "/$"\\ "}
# cut the first two characters
a=${a:2}
# make the full sentence
a="open -a Adobe\ Photoshop\ CC\ 2015 $a"
printf "$a"
最后一个printf的结果是
open -a Adobe\ Photoshop\ CC\ 2015 /Users/me/Downloads/image\ test.jpg
当我将它粘贴到 shell 中时,它可以完美运行,但是当我通过添加运行它时
$a
在我的小脚本中,我有这个问题(字符串被切断)
提前感谢您的帮助:-)
【问题讨论】:
标签: string macos shell automator