Quote shell variables in generated graphics conversion script.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9028 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2004-10-01 14:23:57 +00:00
parent 915304d550
commit cc179cc2a2
2 changed files with 18 additions and 13 deletions

View File

@ -1,3 +1,8 @@
2004-10-01 Angus Leeming <leeming@lyx.org>
* GraphicsConverter.C (move_file, build_script): protect
shell variables with quotes.
2004-09-26 Lars Gullik Bjonnes <larsbj@gullik.net> 2004-09-26 Lars Gullik Bjonnes <larsbj@gullik.net>
* pch.h: use proper signal include * pch.h: use proper signal include

View File

@ -256,13 +256,13 @@ string const move_file(string const & from_file, string const & to_file)
ostringstream command; ostringstream command;
command << "fromfile=" << from_file << "\n" command << "fromfile=" << from_file << "\n"
<< "tofile=" << to_file << "\n\n" << "tofile=" << to_file << "\n\n"
<< "'mv' -f ${fromfile} ${tofile} ||\n" << "'mv' -f \"${fromfile}\" \"${tofile}\" ||\n"
<< "{\n" << "{\n"
<< "\t'cp' -f ${fromfile} ${tofile} ||\n" << "\t'cp' -f \"${fromfile}\" \"${tofile}\" ||\n"
<< "\t{\n" << "\t{\n"
<< "\t\texit 1\n" << "\t\texit 1\n"
<< "\t}\n" << "\t}\n"
<< "\t'rm' -f ${fromfile}\n" << "\t'rm' -f \"${fromfile}\"\n"
<< "}\n"; << "}\n";
return command.str(); return command.str();
@ -328,9 +328,9 @@ bool build_script(string const & from_file,
<< "outfile=" << QuoteName(outfile) << '\n'; << "outfile=" << QuoteName(outfile) << '\n';
string command = conv.command; string command = conv.command;
command = subst(command, token_from, "${infile}"); command = subst(command, token_from, "\"${infile}\"");
command = subst(command, token_base, "${infile_base}"); command = subst(command, token_base, "\"${infile_base}\"");
command = subst(command, token_to, "${outfile}"); command = subst(command, token_to, "\"${outfile}\"");
command = LibScriptSearch(command); command = LibScriptSearch(command);
// Store in the shell script // Store in the shell script
@ -339,7 +339,7 @@ bool build_script(string const & from_file,
// Test that this was successful. If not, remove // Test that this was successful. If not, remove
// ${outfile} and exit the shell script // ${outfile} and exit the shell script
script << "{\n" script << "{\n"
<< "\t'rm' -f ${outfile}\n" << "\t'rm' -f \"${outfile}\"\n"
<< "\texit 1\n" << "\texit 1\n"
<< "}\n\n"; << "}\n\n";
@ -348,10 +348,10 @@ bool build_script(string const & from_file,
// ${outfile}.1. // ${outfile}.1.
// If this occurs, move ${outfile}.0 to ${outfile} // If this occurs, move ${outfile}.0 to ${outfile}
// and delete ${outfile}.? // and delete ${outfile}.?
script << "if [ ! -f ${outfile} ]; then\n" script << "if [ ! -f \"${outfile}\" ]; then\n"
<< "\tif [ -f ${outfile}.0 ]; then\n" << "\tif [ -f \"${outfile}\".0 ]; then\n"
<< "\t\t'mv' -f ${outfile}.0 ${outfile}\n" << "\t\t'mv' -f \"${outfile}\".0 \"${outfile}\"\n"
<< "\t\t'rm' -f ${outfile}.?\n" << "\t\t'rm' -f \"${outfile}\".?\n"
<< "\telse\n" << "\telse\n"
<< "\t\texit 1\n" << "\t\texit 1\n"
<< "\tfi\n" << "\tfi\n"
@ -359,12 +359,12 @@ bool build_script(string const & from_file,
// Delete the infile, if it isn't the original, from_file. // Delete the infile, if it isn't the original, from_file.
if (infile != from_file) { if (infile != from_file) {
script << "'rm' -f ${infile}\n\n"; script << "'rm' -f \"${infile}\"\n\n";
} }
} }
// Move the final outfile to to_file // Move the final outfile to to_file
script << move_file("${outfile}", QuoteName(to_file)); script << move_file("\"${outfile}\"", QuoteName(to_file));
lyxerr[Debug::GRAPHICS] << "ready!" << endl; lyxerr[Debug::GRAPHICS] << "ready!" << endl;
return true; return true;