mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-22 05:55:46 +01:00
minor refactoring of io.system() - add escapeQuotes()
This commit is contained in:
@@ -654,7 +654,6 @@ lookup:
|
|||||||
|
|
||||||
if (!file.exists())
|
if (!file.exists())
|
||||||
{
|
{
|
||||||
// XXX
|
|
||||||
liberator.echoerr("Command not found: " + program);
|
liberator.echoerr("Command not found: " + program);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -675,13 +674,16 @@ lookup:
|
|||||||
var stdoutFile = ioManager.createTempFile();
|
var stdoutFile = ioManager.createTempFile();
|
||||||
var stderrFile = ioManager.createTempFile();
|
var stderrFile = ioManager.createTempFile();
|
||||||
|
|
||||||
|
function escapeQuotes(str) str.replace('"', '\\"');
|
||||||
|
|
||||||
if (!stdoutFile || !stderrFile) // FIXME: error reporting
|
if (!stdoutFile || !stderrFile) // FIXME: error reporting
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
if (WINDOWS)
|
if (WINDOWS)
|
||||||
var command = str + " > " + stdoutFile.path + " 2> " + stderrFile.path;
|
var command = str + " > " + stdoutFile.path + " 2> " + stderrFile.path;
|
||||||
else
|
else
|
||||||
var command = str + " > \"" + stdoutFile.path.replace('"', '\\"') + "\"" + " 2> \"" + stderrFile.path.replace('"', '\\"') + "\"";
|
var command = str + " > \"" + escapeQuotes(stdoutFile.path) + "\""
|
||||||
|
+ " 2> \"" + escapeQuotes(stderrFile.path) + "\"";
|
||||||
|
|
||||||
var stdinFile = null;
|
var stdinFile = null;
|
||||||
|
|
||||||
@@ -689,7 +691,7 @@ lookup:
|
|||||||
{
|
{
|
||||||
stdinFile = ioManager.createTempFile(); // FIXME: no returned file?
|
stdinFile = ioManager.createTempFile(); // FIXME: no returned file?
|
||||||
ioManager.writeFile(stdinFile, input);
|
ioManager.writeFile(stdinFile, input);
|
||||||
command += " < \"" + stdinFile.path.replace('"', '\\"') + "\"";
|
command += " < \"" + escapeQuotes(stdinFile.path) + "\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
var res = ioManager.run(liberator.options["shell"], [liberator.options["shellcmdflag"], command], true);
|
var res = ioManager.run(liberator.options["shell"], [liberator.options["shellcmdflag"], command], true);
|
||||||
|
|||||||
Reference in New Issue
Block a user