processes() improved command parsing
This commit is contained in:
parent
a11719984f
commit
fdcf9c707e
@ -589,36 +589,41 @@ function processes(callback) {
|
|||||||
const p1 = fullcommand.indexOf('(');
|
const p1 = fullcommand.indexOf('(');
|
||||||
const p2 = fullcommand.indexOf(')');
|
const p2 = fullcommand.indexOf(')');
|
||||||
const p3 = fullcommand.indexOf('/');
|
const p3 = fullcommand.indexOf('/');
|
||||||
|
const p4 = fullcommand.indexOf(':');
|
||||||
if (p1 < p2 && p1 < p3 && p3 < p2) {
|
if (p1 < p2 && p1 < p3 && p3 < p2) {
|
||||||
command = fullcommand.split(' ')[0];
|
command = fullcommand.split(' ')[0];
|
||||||
command = command.replace(/:/g, '');
|
command = command.replace(/:/g, '');
|
||||||
} else {
|
} else {
|
||||||
// try to figure out where parameter starts
|
if (p4 > 0) {
|
||||||
let firstParamPos = fullcommand.indexOf(' -');
|
command = fullcommand.split(' ')[0];
|
||||||
let firstParamPathPos = fullcommand.indexOf(' /');
|
} else {
|
||||||
firstParamPos = (firstParamPos >= 0 ? firstParamPos : 10000);
|
// try to figure out where parameter starts
|
||||||
firstParamPathPos = (firstParamPathPos >= 0 ? firstParamPathPos : 10000);
|
let firstParamPos = fullcommand.indexOf(' -');
|
||||||
const firstPos = Math.min(firstParamPos, firstParamPathPos);
|
let firstParamPathPos = fullcommand.indexOf(' /');
|
||||||
let tmpCommand = fullcommand.substr(0, firstPos);
|
firstParamPos = (firstParamPos >= 0 ? firstParamPos : 10000);
|
||||||
const tmpParams = fullcommand.substr(firstPos);
|
firstParamPathPos = (firstParamPathPos >= 0 ? firstParamPathPos : 10000);
|
||||||
const lastSlashPos = tmpCommand.lastIndexOf('/');
|
const firstPos = Math.min(firstParamPos, firstParamPathPos);
|
||||||
if (lastSlashPos >= 0) {
|
let tmpCommand = fullcommand.substr(0, firstPos);
|
||||||
cmdPath = tmpCommand.substr(0, lastSlashPos);
|
const tmpParams = fullcommand.substr(firstPos);
|
||||||
tmpCommand = tmpCommand.substr(lastSlashPos + 1);
|
const lastSlashPos = tmpCommand.lastIndexOf('/');
|
||||||
}
|
if (lastSlashPos >= 0) {
|
||||||
|
cmdPath = tmpCommand.substr(0, lastSlashPos);
|
||||||
|
tmpCommand = tmpCommand.substr(lastSlashPos + 1);
|
||||||
|
}
|
||||||
|
|
||||||
if (firstPos === 10000 && tmpCommand.indexOf(' ') > -1) {
|
if (firstPos === 10000 && tmpCommand.indexOf(' ') > -1) {
|
||||||
const parts = tmpCommand.split(' ');
|
const parts = tmpCommand.split(' ');
|
||||||
if (fs.existsSync(path.join(cmdPath, parts[0]))) {
|
if (fs.existsSync(path.join(cmdPath, parts[0]))) {
|
||||||
command = parts.shift();
|
command = parts.shift();
|
||||||
params = (parts.join(' ') + ' ' + tmpParams).trim();
|
params = (parts.join(' ') + ' ' + tmpParams).trim();
|
||||||
|
} else {
|
||||||
|
command = tmpCommand.trim();
|
||||||
|
params = tmpParams.trim();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
command = tmpCommand.trim();
|
command = tmpCommand.trim();
|
||||||
params = tmpParams.trim();
|
params = tmpParams.trim();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
command = tmpCommand.trim();
|
|
||||||
params = tmpParams.trim();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user