mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 11:17:58 +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:
@@ -129,6 +129,7 @@ function Commands() //{{{
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
var ex_commands = [];
|
||||
var last_run_command = ""; // updated whenever the users runs a command with :!
|
||||
|
||||
function addDefaultCommand(command)
|
||||
{
|
||||
@@ -177,7 +178,6 @@ function Commands() //{{{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// FIXME: doesn't really belong here...
|
||||
// return [null, null, null, null, heredoc_tag || false];
|
||||
// [count, cmd, special, args] = match;
|
||||
@@ -1764,19 +1764,25 @@ function Commands() //{{{
|
||||
addDefaultCommand(new Command(["!", "run"],
|
||||
function(args, special)
|
||||
{
|
||||
// TODO: if special, run the last command
|
||||
// :!! needs to be treated specially as the command parser sets the special flag but removes the ! from args
|
||||
if (special)
|
||||
args = "!" + (args || "");
|
||||
|
||||
// TODO: better escaping of ! to also substitute \\! correctly
|
||||
args = args.replace(/(^|[^\\])!/g, "$1" + last_run_command);
|
||||
last_run_command = args;
|
||||
|
||||
var output = vimperator.system(args)
|
||||
if (typeof output === "string")
|
||||
if (output)
|
||||
vimperator.echo(vimperator.util.escapeHTML(output));
|
||||
else
|
||||
// FIXME: why are we accepting only a string return value from v.system()? -- djk
|
||||
vimperator.echoerr("Invalid system command: " + args);
|
||||
},
|
||||
{
|
||||
usage: ["!{command}"],
|
||||
usage: ["!{cmd}"],
|
||||
short_help: "Run a command",
|
||||
help: "Runs {command} through system() and displays its output. " +
|
||||
"Input redirection (< foo) not done, do not run commands which require stdin or it will hang Firefox!"
|
||||
help: "Runs <code class=\"argument\">{cmd}</code> through system() and displays its output. " +
|
||||
"Any '!' in <code class=\"argument\">{cmd}</code> is replaced with the previous external command. " +
|
||||
"But not when there is a backslash before the '!', then that backslash is removed.<br/>" +
|
||||
"Input redirection (< foo) not done, also do not run commands which require stdin or it will hang Firefox!"
|
||||
}
|
||||
));
|
||||
//}}}
|
||||
|
||||
Reference in New Issue
Block a user