From 14ec281811637f04ef2d2905b3c3c680c14ba0f5 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Sat, 15 Jan 2011 12:16:27 -0500 Subject: [PATCH] Allow relative paths for 'shell'. --- common/bootstrap.js | 4 ---- common/content/options.js | 2 ++ common/modules/io.jsm | 16 ++++++++-------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/common/bootstrap.js b/common/bootstrap.js index dc5609bd..e9c2a066 100755 --- a/common/bootstrap.js +++ b/common/bootstrap.js @@ -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); diff --git a/common/content/options.js b/common/content/options.js index 2df535e3..dbf453de 100644 --- a/common/content/options.js +++ b/common/content/options.js @@ -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); diff --git a/common/modules/io.jsm b/common/modules/io.jsm index 9fde8e52..a83bde28 100644 --- a/common/modules/io.jsm +++ b/common/modules/io.jsm @@ -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",