mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 14:08:11 +01:00
make vimperator.system() Windows aware
This commit is contained in:
2
NEWS
2
NEWS
@@ -11,7 +11,7 @@
|
|||||||
* :let mapleader="," and <Leader> in :map support
|
* :let mapleader="," and <Leader> in :map support
|
||||||
* added new :let and :unlet commands
|
* added new :let and :unlet commands
|
||||||
* :b2 now allowed, no space required before the 2 anymore
|
* :b2 now allowed, no space required before the 2 anymore
|
||||||
* :! to run commands through system() (UNIX only)
|
* :! to run commands through system()
|
||||||
* separated search and Ex command history
|
* separated search and Ex command history
|
||||||
* merge the existing status bar with the standard FF status bar so that
|
* merge the existing status bar with the standard FF status bar so that
|
||||||
security information and extension buttons are included
|
security information and extension buttons are included
|
||||||
|
|||||||
@@ -1647,14 +1647,15 @@ function Commands() //{{{
|
|||||||
// TODO: if special, run the last command
|
// TODO: if special, run the last command
|
||||||
var output = vimperator.system(args)
|
var output = vimperator.system(args)
|
||||||
if (typeof output === "string")
|
if (typeof output === "string")
|
||||||
vimperator.echo(output);
|
vimperator.echo(vimperator.util.escapeHTML(output));
|
||||||
else
|
else
|
||||||
|
// FIXME: why are we accepting only a string return value from v.system()? -- djk
|
||||||
vimperator.echoerr("Invalid system command: " + args);
|
vimperator.echoerr("Invalid system command: " + args);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
usage: "!{command}",
|
usage: ["!{command}"],
|
||||||
short_help: "Run a command",
|
short_help: "Run a command",
|
||||||
help: "Runs {command} through system() and displays its output." +
|
help: "Runs {command} through system() and displays its output. " +
|
||||||
"Input redirection (< foo) not done, do not run commands which require stdin or it will hang Firefox!"
|
"Input redirection (< foo) not done, do not run commands which require stdin or it will hang Firefox!"
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
|||||||
@@ -582,17 +582,22 @@ const vimperator = (function() //{{{
|
|||||||
|
|
||||||
// when https://bugzilla.mozilla.org/show_bug.cgi?id=68702 is fixed
|
// when https://bugzilla.mozilla.org/show_bug.cgi?id=68702 is fixed
|
||||||
// is fixed, should use that instead of a tmpfile
|
// is fixed, should use that instead of a tmpfile
|
||||||
// TODO: make it usable on windows
|
|
||||||
// TODO: pass "input" as stdin
|
// TODO: pass "input" as stdin
|
||||||
// TODO: add shell/shellcmdflag options to replace "sh" and "-c"
|
// TODO: add shell/shellcmdflag options to replace "sh" and "-c"
|
||||||
system: function (str, input)
|
system: function (str, input)
|
||||||
{
|
{
|
||||||
|
const WINDOWS = navigator.platform == "Win32"; // FIXME: duplicated everywhere
|
||||||
|
|
||||||
var fileout = getTempFile();
|
var fileout = getTempFile();
|
||||||
if (!fileout)
|
if (!fileout)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
|
if (WINDOWS)
|
||||||
|
var command = str + " > " + fileout.path;
|
||||||
|
else
|
||||||
|
var command = str + " > \"" + fileout.path.replace('"', '\\"') + "\"";
|
||||||
|
|
||||||
var filein = null;
|
var filein = null;
|
||||||
var command = str + " > \"" + fileout.path.replace('"', '\\"') + "\"";
|
|
||||||
if (input)
|
if (input)
|
||||||
{
|
{
|
||||||
filein = getTempFile();
|
filein = getTempFile();
|
||||||
@@ -602,7 +607,11 @@ const vimperator = (function() //{{{
|
|||||||
command += " < \"" + filein.path.replace('"', '\\"') + "\"";
|
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, "<");
|
var fd = vimperator.fopen(fileout, "<");
|
||||||
if (!fd)
|
if (!fd)
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user