1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 06:17:58 +01:00

output an error message when trying to expand ! in a :! command if there was no

previous command
This commit is contained in:
Doug Kearns
2008-10-30 05:39:11 +00:00
parent fd0d20b42c
commit 4de6674df7

View File

@@ -342,11 +342,22 @@ function IO() //{{{
// :!! needs to be treated specially as the command parser sets the
// special flag but removes the ! from args
if (special)
args = "!" + (args || "");
args = "!" + args;
// TODO: Hmmm, actually Vim doesn't handle multiple backslashes and documents it - desirable?
args = args.replace(/((?:^|[^\\])(?:\\\\)*)!/g, function (m, n) n != null ? n + lastRunCommand : m)
lastRunCommand = args;
// replaceable bang and no previous command?
if (/((^|[^\\])(\\\\)*)!/.test(args) && !lastRunCommand)
{
liberator.echoerr("E34: No previous command");
return;
}
// NOTE: Vim doesn't replace ! preceded by 2 or more backslashes and documents it - desirable?
// pass through a raw bang when escaped or substitute the last command
args = args.replace(/(\\)*!/g,
function (m) /^\\(\\\\)*!$/.test(m) ? m.replace("\\!", "!") : m.replace("!", lastRunCommand)
);
lastRunCommand = args
let output = io.system(args);
let command = ":" + util.escapeHTML(commandline.getCommand()) + "<br/>";