Running embedFonts on filenames with spaces results in an error, because the filename isn't escaped or quoted in the internal call to ghostscript.
Steps to reproduce:
1) Run embedFonts on a filename with spaces.
* Error is raised
> embedFonts(file='../output/Two words/example.pdf')
Error: /undefinedfilename in (../output/Two)
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push
--dict:1168/1684(ro)(G)-- --dict:0/20(G)-- --dict:77/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
GPL Ghostscript 9.06: Unrecoverable error, exit code 1
Error in embedFonts(file = "../output/Two words/example.pdf") :
status 1 in running command 'gs -dNOPAUSE -dBATCH -q -dAutoRotatePages=/None -sDEVICE=pdfwrite -sOutputFile=/tmp/Rtmpu7SL0u/Rembed93237016e29 -sFONTPATH= ../output/Two words/example.pdf'
Enter a frame number, or 0 to exit
1: embedFonts(file = "../output/Two words/example.pdf")
It does not 'crash': see the R posting guide for the proper use of that word.
The short answr is 'don't do that' (on Linux: why?). But shQuote() has been added.
(In reply to comment #1)
> The short answr is 'don't do that' (on Linux: why?).
There's a few reasons:
1) I have a cross-platform development team and the developers on non-linux OSes prefer names with spaces. As it works for them, they will have a hard time remembering not to use them.
2) Many of our filenames are generated automatically based on data structures, whose names are in turn imported from our data sources. We like to keep the original names around so that they appear in a friendly way as graph labels; maintaining separate names for filenames and graph labels is certainly possible, but its unnecessary overhead except for this one call (before your fix).
> But shQuote() has been added.