If you make a run handler for the script, you can test everything in the script editor, and actually see which event returns the wrong result, and how to get the desired result.
I’ve split up the script, and because we are running from the script editor, we have to be a bit more explicit as to whom we’re talking to.
on docSave(docinfo)
tell application "BBEdit"
set docpath to POSIX path of file of docinfo
-- return file of docinfo
-- set docpath to (POSIX path of ((file of docinfo) as alias))
end tell
tell application "Terminal"
activate
do script "ls " & quoted form of docpath
end tell
end docSave
using terms from application "BBEdit"
on documentDidSave(docinfo)
docSave(docinfo)
end documentDidSave
end using terms from
on run
tell application "BBEdit" to set docinfo to document 1 of window 1
tell me to docSave(docinfo)
end run
-- End of script
When we run this, we see where things go wrong, and then suggestions what we need to inspect follow naturally: If we execute the first commented line we see that we get a file object. Apparently this does not know about POSIX paths (although the StandardAdditions dictionary says otherwise). However, if you turn the file object into an alias (second comment), then the POSIX path will do its magic.
Keep in mind that the do shell script command is limited, and that the output may not be available in an obvious way.
Maarten