1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 14:27:58 +01:00

make vimperator.system() Windows aware

This commit is contained in:
Doug Kearns
2007-10-06 14:35:38 +00:00
parent 505cc2d0ed
commit c4cddc478d
3 changed files with 17 additions and 7 deletions

View File

@@ -582,17 +582,22 @@ const vimperator = (function() //{{{
// when https://bugzilla.mozilla.org/show_bug.cgi?id=68702 is fixed
// is fixed, should use that instead of a tmpfile
// TODO: make it usable on windows
// TODO: pass "input" as stdin
// TODO: add shell/shellcmdflag options to replace "sh" and "-c"
system: function (str, input)
{
const WINDOWS = navigator.platform == "Win32"; // FIXME: duplicated everywhere
var fileout = getTempFile();
if (!fileout)
return "";
if (WINDOWS)
var command = str + " > " + fileout.path;
else
var command = str + " > \"" + fileout.path.replace('"', '\\"') + "\"";
var filein = null;
var command = str + " > \"" + fileout.path.replace('"', '\\"') + "\"";
if (input)
{
filein = getTempFile();
@@ -602,7 +607,11 @@ const vimperator = (function() //{{{
command += " < \"" + filein.path.replace('"', '\\"') + "\"";
}
this.run("sh", ["-c", command], true);
if (WINDOWS)
this.run("cmd.exe", ["/C", command], true);
else
this.run("sh", ["-c", command], true);
var fd = vimperator.fopen(fileout, "<");
if (!fd)
return null;