mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 08:17:59 +01:00
output an error message when trying to expand ! in a :! command if there was no
previous command
This commit is contained in:
@@ -342,11 +342,22 @@ function IO() //{{{
|
|||||||
// :!! needs to be treated specially as the command parser sets the
|
// :!! needs to be treated specially as the command parser sets the
|
||||||
// special flag but removes the ! from args
|
// special flag but removes the ! from args
|
||||||
if (special)
|
if (special)
|
||||||
args = "!" + (args || "");
|
args = "!" + args;
|
||||||
|
|
||||||
// TODO: Hmmm, actually Vim doesn't handle multiple backslashes and documents it - desirable?
|
// replaceable bang and no previous command?
|
||||||
args = args.replace(/((?:^|[^\\])(?:\\\\)*)!/g, function (m, n) n != null ? n + lastRunCommand : m)
|
if (/((^|[^\\])(\\\\)*)!/.test(args) && !lastRunCommand)
|
||||||
lastRunCommand = args;
|
{
|
||||||
|
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 output = io.system(args);
|
||||||
let command = ":" + util.escapeHTML(commandline.getCommand()) + "<br/>";
|
let command = ":" + util.escapeHTML(commandline.getCommand()) + "<br/>";
|
||||||
|
|||||||
Reference in New Issue
Block a user