2012-05-12 82 views
0

我想添加一个脚本到BBEdit 10将验证PHP文件。我在我的Mac上启用了PHP &网络共享,我认为该脚本是准确的,但我认为这是由具有空间的卷名引起的问题。PHP验证BBEdit 10与苹果脚本

property phpref : "/usr/bin/php -l " 
try 
    tell application "BBEdit" to get file of first text window 
    do shell script phpref & POSIX path of result 
    display dialog "Ok: " & result buttons {"Finished Checking"} default button 1 
on error msg 
    display dialog "Err: " & msg buttons {"Finished Checking"} default button 1 
end try 

我收到一个错误get file of。错误是:无法打开输入文件:/卷/数据

卷的名称是“数据HD”,这就是为什么我认为空间导致问题。致电get file of时,我可以逃脱一个空间吗?

回答

2

该问题在另一个网站上得到解答。我想分享最终答案。问题不在于获取文件。它是在命令行中使用文件路径。

这是正确的,工作scripr:

property phpref : "/usr/bin/php -l " 
try 
    tell application "BBEdit" to get file of first text window 
    do shell script phpref & quoted form of POSIX path of result 
    display dialog "Ok: " & result buttons {"Finished Checking"} default button 1 
on error msg 
    display dialog "Err: " & msg buttons {"Finished Checking"} default button 1 
end try 
+0

通过设置XXX POSIX的路径引号形式...你准备的命令行命令。您的解决方案和我的结果相同。 – adayzdone

0

我无法测试,但尝试:

tell application "BBEdit" to set xxx to quoted form of POSIX path of (get file of first text window) 
do shell script phpref & xxx 

在Finder中,它会是这个样子:

tell application "Finder" to set xxx to quoted form of POSIX path of (get file 1 of desktop as alias) 

您是否尝试过暂时重命名卷没有空间来验证这是问题的原因?