Can view_command correctly handle quotations?
So I'm trying to set up a new view_command for macOS to open PDFs using PDF Expert. My view_command looks like below but it doesn't work:
"osx" : {
"view_command": "open -a \"PDF Expert\""
},
When I replace it with "open -a Preview" it works fine so I guess it's something to do with the fact that the name of the app has spaces in it and needs to be in quotations.
I also tried "open -a PDF\ Expert" but it doesn't work either.
Am I doing something wrong?
If I rename the app to PDFExpert and use "view_command": "open -a PDFExpert" then everything works fine so it must be something to do with the name.
I strongly suspect this is due to the internal metadata PDF Expert reports to macOS. I can run open -a "Google Chrome" (for example) as a viewer command perfectly well. Unfortunately, I don’t have the $60 to install the app from the App Store and I’m not willing to run their installer on my machine so I can’t test this out, but I suspect you can use open -a PDFExpert without renaming the app and it will work.
Actually Google Chrome is a good example because that doesn't work for me either. Could you please share your viewer command for chrome?
It's just this:
"viewer": "command",
"viewer_settings": {
"osx": {
"view_command": "open -a \"Google Chrome\""
}
}
Interesting, that does not work for me.
That's weird... Some questions / things to try:
- Do you use a shell other than
bash? (If that question's meaningless to you, the answer is no). - If you open the console you should see a line something like the one below. Do you see this line?
Running "open -a 'PDF Expert' /some/path/here"
- Does running
open -a "PDF Expert" /path/to/your/pdffile.pdfdo what you expect when run from the Terminal app?
- I use
zsh. I tried spawning Sublime frombashbut doesn't seem to make a difference - I do:
Running "open -a '"Google Chrome"' '/some/path/file.pdf'" - Yes that works fine in a
zshterminal
Looking at the console, I think the problem is in those additional single quotes
It's an issue with this line: https://github.com/SublimeText/LaTeXTools/blob/9aa34a033c3ea7fd649a0ee362f027aee0ab3cb4/viewers/command_viewer.py#L113
Here is some sample output:
>>> shlex.split("open -a \"Google Chrome\"", False, False)
['open', '-a', '"Google Chrome"']
You can use the following instead:
>>> shlex.split("open -a \"Google Chrome\"", False)
['open', '-a', 'Google Chrome']
I'm also having this issue. Should I submit a PR with the fix @Isolus suggested?
YES YES