mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-12 23:15:46 +01:00
add :!! support and don't show error on :!non-existing-command (as the non-existing-command can't be known if it really does not exist)
This commit is contained in:
@@ -543,10 +543,15 @@ const vimperator = (function() //{{{
|
||||
|
||||
run: function(program, args, blocking)
|
||||
{
|
||||
var file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
|
||||
const WINDOWS = navigator.platform == "Win32";
|
||||
|
||||
var file = Components.classes["@mozilla.org/file/local;1"].
|
||||
createInstance(Components.interfaces.nsILocalFile);
|
||||
if (!args)
|
||||
args = [];
|
||||
|
||||
if (typeof(blocking) != "boolean")
|
||||
blocking = false;
|
||||
|
||||
try
|
||||
{
|
||||
file.initWithPath(program);
|
||||
@@ -566,14 +571,14 @@ const vimperator = (function() //{{{
|
||||
catch (e) { }
|
||||
}
|
||||
}
|
||||
|
||||
if (!file.exists())
|
||||
{
|
||||
vimperator.echoerr("command not found: " + program);
|
||||
return -1;
|
||||
}
|
||||
|
||||
var process = Components.classes["@mozilla.org/process/util;1"].
|
||||
createInstance(Components.interfaces.nsIProcess);
|
||||
var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
|
||||
process.init(file);
|
||||
|
||||
var ec = process.run(blocking, args, args.length);
|
||||
@@ -582,7 +587,6 @@ 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: pass "input" as stdin
|
||||
// TODO: add shell/shellcmdflag options to replace "sh" and "-c"
|
||||
system: function (str, input)
|
||||
{
|
||||
@@ -607,14 +611,15 @@ const vimperator = (function() //{{{
|
||||
command += " < \"" + filein.path.replace('"', '\\"') + "\"";
|
||||
}
|
||||
|
||||
var res;
|
||||
if (WINDOWS)
|
||||
this.run("cmd.exe", ["/C", command], true);
|
||||
res = this.run("cmd.exe", ["/C", command], true);
|
||||
else
|
||||
this.run("sh", ["-c", command], true);
|
||||
res = this.run("sh", ["-c", command], true);
|
||||
|
||||
var fd = vimperator.fopen(fileout, "<");
|
||||
if (!fd)
|
||||
return null;
|
||||
return "";
|
||||
|
||||
var s = fd.read();
|
||||
fd.close();
|
||||
@@ -622,6 +627,10 @@ const vimperator = (function() //{{{
|
||||
if (filein)
|
||||
filein.remove(false);
|
||||
|
||||
// if there is only one \n at the end, chop it off
|
||||
if (s && s.indexOf("\n") == s.length-1)
|
||||
s = s.substr(0, s.length-1);
|
||||
|
||||
return s;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user