diff --git a/NEWS b/NEWS index 10398beb..8ead2b7f 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,7 @@ generous donation which made this behavior possible) * IMPORTANT: ctrl-x/a never take possible negative URLs into account, it was just too unpredictable + * add 'shell' and 'shellcmdflag' options * :tabprevious, :bprevious, :tabnext, :bnext and friends now accept a prefix count * add :comclear and :delcommand * add a special version to :hardcopy to skip the Print dialog diff --git a/content/io.js b/content/io.js index d64ca700..df8fe47d 100644 --- a/content/io.js +++ b/content/io.js @@ -41,6 +41,34 @@ liberator.IO = function () //{{{ var extname = liberator.config.name.toLowerCase(); // "vimperator" or "muttator" var lastRunCommand = ""; // updated whenever the users runs a command with :! + /////////////////////////////////////////////////////////////////////////////}}} + ////////////////////// OPTIONS //////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////{{{ + + var shell, shellcmdflag; + + if (WINDOWS) + { + shell = "cmd.exe"; + // TODO: does setting 'shell' to "something containing sh" + // automatically update 'shellcmdflag' on Windows in Vim? + shellcmdflag = "/c"; + } + else + { + shell = environmentService.get("SHELL") || "sh"; + shellcmdflag = "-c"; + } + + // TODO: setter should expand environment variables + liberator.options.add(["shell", "sh"], + "Shell to use for executing :! and :run commands", + "string", shell); + + liberator.options.add(["shellcmdflag", "shcf"], + "Flag passed to shell when executing :! and :run commands", + "string", shellcmdflag); + /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// COMMANDS //////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ @@ -507,7 +535,6 @@ lookup: // when https://bugzilla.mozilla.org/show_bug.cgi?id=68702 is fixed // is fixed, should use that instead of a tmpfile - // TODO: add shell/shellcmdflag options to replace "sh" and "-c" system: function (str, input) { var fileout = ioManager.createTempFile(); @@ -527,11 +554,8 @@ lookup: command += " < \"" + filein.path.replace('"', '\\"') + "\""; } - var res; - if (WINDOWS) - res = ioManager.run("cmd.exe", ["/C", command], true); - else - res = ioManager.run("sh", ["-c", command], true); + // FIXME: why is this return value being ignored? + var res = ioManager.run(liberator.options["shell"], [liberator.options["shellcmdflag"], command], true); var output = ioManager.readFile(fileout); fileout.remove(false); diff --git a/locale/en-US/options.txt b/locale/en-US/options.txt index 3bd74cea..234e9c72 100644 --- a/locale/en-US/options.txt +++ b/locale/en-US/options.txt @@ -528,13 +528,29 @@ value can be reset to half the window height with [c]:set scroll=0[c]. ____ -|\'nosmd'| |\'noshowmode'| |\'smd'| |\'showmode'| -||'showmode' 'smd'|| boolean (default: on) +|\'shell'| |\'sh'| +||'shell' 'sh'|| string (default: on) ____ Show the current mode in the command line. ____ +|\'shellcmdflag'| |\'shcf'| +||'shellcmdflag' 'shcf'|| string (default: $SHELL or "sh", Win32: "cmd.exe") +____ +Shell to use for executing :! and :run commands. +____ + + +|\'nosmd'| |\'noshowmode'| |\'smd'| |\'showmode'| +||'showmode' 'smd'|| boolean (default: "-c", Win32: "/c") +____ +Flag passed to shell when executing :! and :run commands. + +E.g. bash -c gvim +____ + + |\'ssli'| |\'showstatuslinks'| ||'showstatuslinks' 'ssli'|| number (default: 1) ____