mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 21:58:00 +01:00
Die on unclosed quote
This commit is contained in:
@@ -463,7 +463,15 @@ function Commands() //{{{
|
|||||||
// using literal etc
|
// using literal etc
|
||||||
parseArgs: function (str, options, argCount, allowUnknownOptions, literal, complete, extra)
|
parseArgs: function (str, options, argCount, allowUnknownOptions, literal, complete, extra)
|
||||||
{
|
{
|
||||||
function getNextArg(str) commands.parseArg(str);
|
function getNextArg(str)
|
||||||
|
{
|
||||||
|
let [count, arg, quote] = commands.parseArg(str);
|
||||||
|
if (quote == "\\" && !complete)
|
||||||
|
return [,,,"Trailing \\"];
|
||||||
|
if (quote && !complete)
|
||||||
|
return [,,,"E114: Missing quote: " + quote];
|
||||||
|
return [count, arg, quote];
|
||||||
|
}
|
||||||
|
|
||||||
if (!options)
|
if (!options)
|
||||||
options = [];
|
options = [];
|
||||||
@@ -555,9 +563,9 @@ function Commands() //{{{
|
|||||||
let sep = sub[optname.length];
|
let sep = sub[optname.length];
|
||||||
if (sep == "=" || /\s/.test(sep) && opt[1] != this.OPTION_NOARG)
|
if (sep == "=" || /\s/.test(sep) && opt[1] != this.OPTION_NOARG)
|
||||||
{
|
{
|
||||||
[count, arg, quote] = getNextArg(sub.substr(optname.length + 1));
|
[count, arg, quote, error] = getNextArg(sub.substr(optname.length + 1));
|
||||||
if (quote == "\\" && !complete)
|
if (error)
|
||||||
return liberator.echoerr("Trailing \\");
|
return liberator.echoerr(error);
|
||||||
|
|
||||||
// if we add the argument to an option after a space, it MUST not be empty
|
// if we add the argument to an option after a space, it MUST not be empty
|
||||||
if (sep != "=" && !quote && arg.length == 0)
|
if (sep != "=" && !quote && arg.length == 0)
|
||||||
@@ -646,9 +654,9 @@ function Commands() //{{{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if not an option, treat this token as an argument
|
// if not an option, treat this token as an argument
|
||||||
var [count, arg, quote] = getNextArg(sub);
|
let [count, arg, quote, error] = getNextArg(sub);
|
||||||
if (quote == "\\" && !complete)
|
if (error)
|
||||||
return liberator.echoerr("Trailing \\");
|
return liberator.echoerr(error);
|
||||||
|
|
||||||
if (complete)
|
if (complete)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user