I'm trying to write a command that will open the current document in an external app, here is what I've got:
open -a Final\ Draft\ 7 $TM_FILEPATH
The problem I'm having is that the FilePath (as constructed by TextMate) does not insert "" before a space, thus the command in question is unable to find documents with spaces in the filenames to pass on to the external app.
Is there another way to do it? What am I missing?
On 2/2/2006, at 1:56, Oliver Taylor wrote:
Is there another way to do it? What am I missing?
ALWAYS quote shell variables! Otherwise the shell does various forms of parsing after expanding it. So the line should be:
open -a Final\ Draft\ 7 "$TM_FILEPATH"
And this is a very common mistake btw. I won't rule out that several of the TM default commands show it as well (though I generally fix it when I see people commit scripts with unquoted variables).
On 02/02/2006, at 2:03, Allan Odgaard wrote:
ALWAYS quote shell variables! Otherwise the shell does various forms of parsing after expanding it. So the line should be: open -a Final\ Draft\ 7 "$TM_FILEPATH"
And I would also quote the application name, as less errors tend to happen in the long run when doing that, but of course escaping space also works.
-- Sune.