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

system() returns the stdout string now, still not working on windows

is createUnique secure? I doubt it, biesi from #extdev thinks so
This commit is contained in:
Martin Stubenschrott
2007-09-23 16:56:17 +00:00
parent af04463585
commit 3836640e4f

View File

@@ -503,11 +503,26 @@ const vimperator = (function() //{{{
var ec = process.run(blocking, args, args.length); var ec = process.run(blocking, args, args.length);
return ec; return ec;
}, },
// should return the stdout of the program instead of the error code when // when https://bugzilla.mozilla.org/show_bug.cgi?id=68702 is fixed
// 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: check for errors/insecurities
system: function (str) system: function (str)
{ {
return this.run("sh", ["-c", str], true); var file = Components.classes["@mozilla.org/file/local;1"].
createInstance(Components.interfaces.nsILocalFile);
var dir = environment_service.get("TMP") || environment_service.get("TEMP") || "/tmp/";
file.initWithPath(dir + "vimperator.tmp");
file.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0600);
this.run("sh", ["-c", str + " > " + file.path], true);
var fd = vimperator.fopen(file, "<");
if (!fd)
return null;
var s = fd.read();
fd.close();
file.remove(false);
return s;
}, },
// files which end in .js are sourced as pure javascript files, // files which end in .js are sourced as pure javascript files,