processes() fixed issue truncated params

This commit is contained in:
Sebastian Hildebrandt 2021-02-11 21:29:52 +01:00
parent 40b16dac9a
commit be0a5c66af
4 changed files with 33 additions and 25 deletions

View File

@ -72,6 +72,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
| Version | Date | Comment |
| -------------- | -------------- | -------- |
| 5.2.5 | 2020-02-11 | `processes()` fixed truncated params (linux) |
| 5.2.4 | 2020-02-11 | `currentLoad()` fixed issue |
| 5.2.3 | 2020-02-11 | `diskLayout()` added USB drives (mac OS) |
| 5.2.2 | 2020-02-11 | code cleanup, updated docs |

View File

@ -56,6 +56,11 @@
</tr>
</thead>
<tbody>
<tr>
<th scope="row">5.2.5</th>
<td>2020-02-11</td>
<td><span class="code">processes()</span> fix truncated params (linux)</td>
</tr>
<tr>
<th scope="row">5.2.4</th>
<td>2020-02-11</td>

View File

@ -170,7 +170,7 @@
<img class="logo" src="assets/logo.png">
<div class="title">systeminformation</div>
<div class="subtitle"><span id="typed"></span>&nbsp;</div>
<div class="version">New Version: <span id="version">5.2.4</span></div>
<div class="version">New Version: <span id="version">5.2.5</span></div>
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
</div>
<div class="down">

View File

@ -525,38 +525,40 @@ function processes(callback) {
checkColumn(11);
const user = line.substring(parsedhead[11].from + offset, parsedhead[11].to + offset2).trim();
checkColumn(12);
let fullcommand = line.substring(parsedhead[12].from + offset, parsedhead[12].to + offset2).trim();
if (fullcommand.substr(0, 1) === '[') { fullcommand = fullcommand.substring(1); }
if (fullcommand.substr(fullcommand.length - 1) === ']') { fullcommand = fullcommand.slice(0, -1); }
let cmdPath = '';
let command = '';
let params = '';
// try to figure out where parameter starts
let firstParamPos = fullcommand.indexOf(' -');
let firstParamPathPos = fullcommand.indexOf(' /');
firstParamPos = (firstParamPos >= 0 ? firstParamPos : 10000);
firstParamPathPos = (firstParamPathPos >= 0 ? firstParamPathPos : 10000);
const firstPos = Math.min(firstParamPos, firstParamPathPos);
let tmpCommand = fullcommand.substr(0, firstPos);
const tmpParams = fullcommand.substr(firstPos);
const lastSlashPos = tmpCommand.lastIndexOf('/');
if (lastSlashPos >= 0) {
cmdPath = tmpCommand.substr(0, lastSlashPos);
tmpCommand = tmpCommand.substr(lastSlashPos + 1);
}
let fullcommand = line.substring(parsedhead[12].from + offset, parsedhead[12].to + offset2).trim();
if (fullcommand.substr(fullcommand.length - 1) === ']') { fullcommand = fullcommand.slice(0, -1); }
if (fullcommand.substr(0, 1) === '[') { command = fullcommand.substring(1); }
else {
// try to figure out where parameter starts
let firstParamPos = fullcommand.indexOf(' -');
let firstParamPathPos = fullcommand.indexOf(' /');
firstParamPos = (firstParamPos >= 0 ? firstParamPos : 10000);
firstParamPathPos = (firstParamPathPos >= 0 ? firstParamPathPos : 10000);
const firstPos = Math.min(firstParamPos, firstParamPathPos);
let tmpCommand = fullcommand.substr(0, firstPos);
const tmpParams = fullcommand.substr(firstPos);
const lastSlashPos = tmpCommand.lastIndexOf('/');
if (lastSlashPos >= 0) {
cmdPath = tmpCommand.substr(0, lastSlashPos);
tmpCommand = tmpCommand.substr(lastSlashPos + 1);
}
if (firstPos === 10000 && tmpCommand.indexOf(' ') > -1) {
const parts = tmpCommand.split(' ');
if (fs.existsSync(path.join(cmdPath, parts[0]))) {
command = parts.shift();
params = (parts.join(' ') + ' ' + tmpParams).trim();
if (firstPos === 10000 && tmpCommand.indexOf(' ') > -1) {
const parts = tmpCommand.split(' ');
if (fs.existsSync(path.join(cmdPath, parts[0]))) {
command = parts.shift();
params = (parts.join(' ') + ' ' + tmpParams).trim();
} else {
command = tmpCommand.trim();
params = tmpParams.trim();
}
} else {
command = tmpCommand.trim();
params = tmpParams.trim();
}
} else {
command = tmpCommand.trim();
params = tmpParams.trim();
}
return ({