1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-24 07:42:26 +01:00

minor refactoring of io.system() - add escapeQuotes()

This commit is contained in:
Doug Kearns
2008-09-23 02:40:12 +00:00
parent 398f93f5e1
commit ed327496ff

View File

@@ -654,7 +654,6 @@ lookup:
if (!file.exists())
{
// XXX
liberator.echoerr("Command not found: " + program);
return -1;
}
@@ -675,13 +674,16 @@ lookup:
var stdoutFile = ioManager.createTempFile();
var stderrFile = ioManager.createTempFile();
function escapeQuotes(str) str.replace('"', '\\"');
if (!stdoutFile || !stderrFile) // FIXME: error reporting
return "";
if (WINDOWS)
var command = str + " > " + stdoutFile.path + " 2> " + stderrFile.path;
else
var command = str + " > \"" + stdoutFile.path.replace('"', '\\"') + "\"" + " 2> \"" + stderrFile.path.replace('"', '\\"') + "\"";
var command = str + " > \"" + escapeQuotes(stdoutFile.path) + "\""
+ " 2> \"" + escapeQuotes(stderrFile.path) + "\"";
var stdinFile = null;
@@ -689,7 +691,7 @@ lookup:
{
stdinFile = ioManager.createTempFile(); // FIXME: no returned file?
ioManager.writeFile(stdinFile, input);
command += " < \"" + stdinFile.path.replace('"', '\\"') + "\"";
command += " < \"" + escapeQuotes(stdinFile.path) + "\"";
}
var res = ioManager.run(liberator.options["shell"], [liberator.options["shellcmdflag"], command], true);