1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-05 16:05:46 +01:00

Allow relative paths for 'shell'.

This commit is contained in:
Kris Maglione
2011-01-15 12:16:27 -05:00
parent c78c7b36cb
commit 14ec281811
3 changed files with 10 additions and 12 deletions

4
common/bootstrap.js vendored
View File

@@ -52,10 +52,6 @@ function startup(data, reason) {
addon = data;
AddonManager.getAddonByID(addon.id, function (a) { addon = a; });
// Temporary hack.
if (basePath.isDirectory() && global.JSMLoader && JSMLoader.bump == null)
JSMLoader.bump = 2;
if (basePath.isDirectory())
getURI = function getURI(path) {
let file = basePath.clone().QueryInterface(Ci.nsILocalFile);

View File

@@ -673,11 +673,13 @@ var Options = Module("options", {
memoize(this._optionMap, name, function () Option(names, description, type, defaultValue, extraInfo));
for (let alias in values(names.slice(1)))
memoize(this._optionMap, alias, closure);
if (extraInfo.setter && (!extraInfo.scope || extraInfo.scope & Option.SCOPE_GLOBAL))
if (dactyl.initialized)
closure().initValue();
else
memoize(this.needInit, this.needInit.length, closure);
this._floptions = (this._floptions || []).concat(name);
memoize(this._options, this._options.length, closure);

View File

@@ -332,6 +332,9 @@ var IO = Module("io", {
},
pathSearch: function (bin) {
if (bin instanceof File || File.isAbsolutePath(bin))
return this.File(bin);
let dirs = services.environment.get("PATH").split(util.OS.isWindows ? ";" : ":");
// Windows tries the CWD first TODO: desirable?
if (util.OS.isWindows)
@@ -368,12 +371,7 @@ var IO = Module("io", {
run: function (program, args, blocking) {
args = args || [];
let file;
if (program instanceof File || File.isAbsolutePath(program))
file = this.File(program, true);
else
file = this.pathSearch(program);
let file = this.pathSearch(program);
if (!file || !file.exists()) {
util.dactyl.echoerr("Command not found: " + program);
@@ -425,8 +423,9 @@ var IO = Module("io", {
else if (input)
stdin.write(input);
let shell = File(storage["options"].get("shell").value);
let shell = io.pathSearch(storage["options"].get("shell").value);
let shcf = storage["options"].get("shellcmdflag").value;
util.assert(shell, "Invalid 'shell'");
if (isArray(command))
command = command.map(escape).join(" ");
@@ -1009,7 +1008,8 @@ unlet s:cpo_save
options.add(["shell", "sh"],
"Shell to use for executing external commands with :! and :run",
"string", shell);
"string", shell,
{ validator: function (val) io.pathSearch(val) });
options.add(["shellcmdflag", "shcf"],
"Flag passed to shell when executing external commands with :! and :run",