Make the script robust in the face of 'complex args' such as file names

with spaces in them.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_3_X@8840 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2004-07-21 09:02:19 +00:00
parent 1d4b2ab362
commit 77b0093315
2 changed files with 17 additions and 11 deletions

View File

@ -1,3 +1,13 @@
2004-07-21 Angus Leeming <leeming@lyx.org>
* scripts/lyxpreview2ppm.py: protect arguments of external
program calls correctly. Confirmed that this does not break
usage of the script by lyx on either *nix or win32 platforms.
Also confirmed that this allows the script to be used to
generate successfully on Win32 with an input file such as
"my dir/my file.tex". (MikTeX has no problem with spaces in
file names, so the script should work in such cases too.)
2004-07-14 Angus Leeming <leeming@lyx.org>
* scripts/lyxpreview2ppm.py: improve the commentary, both in
@ -14,10 +24,6 @@
* configure.m4: adjust lyxpreview_to_bitmap_command.
2004-05-05 Angus Leeming <leeming@lyx.org>
* scripts/lyxpreview2bitmap.sh: enable the script to work on
2004-05-19 Uwe Stöhr <uwestoehr@web.de>
* lib/math.bind: fix some bindings to work with german keyboard;

View File

@ -307,8 +307,8 @@ def mkstemp():
def crop_files(pnmcrop, basename):
t = pipes.Template()
t.append('%s -left' % pnmcrop, '--')
t.append('%s -right' % pnmcrop, '--')
t.append('"%s" -left' % pnmcrop, '--')
t.append('"%s" -right' % pnmcrop, '--')
for file in glob.glob("%s*.ppm" % basename):
tmp = mkstemp()
@ -340,7 +340,7 @@ def main(argv):
pnmcrop = find_exe(["pnmcrop"], path)
# Compile the latex file.
latex_call = '%s %s' % (latex, latex_file)
latex_call = '"%s" "%s"' % (latex, latex_file)
latex_status, latex_stdout = run_command(latex_call)
if latex_status != None:
@ -351,7 +351,7 @@ def main(argv):
dvi_file = latex_file_re.sub(".dvi", latex_file)
ps_file = latex_file_re.sub(".ps", latex_file)
dvips_call = '%s -o %s %s' % (dvips, ps_file, dvi_file)
dvips_call = '"%s" -o "%s" "%s"' % (dvips, ps_file, dvi_file)
dvips_status, dvips_stdout = run_command(dvips_call)
if dvips_status != None:
@ -368,10 +368,10 @@ def main(argv):
alpha = 2
# Generate the bitmap images
gs_call = '%s -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pnmraw ' \
'-sOutputFile=%s%%d.ppm ' \
gs_call = '"%s" -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pnmraw ' \
'-sOutputFile="%s%%d.ppm" ' \
'-dGraphicsAlphaBit=%d -dTextAlphaBits=%d ' \
'-r%f %s' \
'-r%f "%s"' \
% (gs, latex_file_re.sub("", latex_file), \
alpha, alpha, resolution, ps_file)