brsh 3.10.1 → 3.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/shell.es.js +46 -13
- package/dist/shell.es.js.map +1 -1
- package/dist/shell.min.js +2 -2
- package/dist/shell.min.js.map +1 -1
- package/dist/wbt.es.js +20 -8
- package/dist/wbt.es.js.map +1 -1
- package/dist/wbt.min.js +1 -1
- package/dist/wbt.min.js.map +1 -1
- package/index.js +43 -9
- package/lib/ScriptCommand.js +19 -7
- package/package.json +1 -1
- package/test/scripts.test.js +48 -0
- package/test/shell.test.js +60 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [3.10.2](https://github.com/eliotstocker/Brsh-JS/compare/v3.10.1...v3.10.2) (2026-11-11)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **shell:** perform POSIX word splitting on unquoted expansions and preserve "$@" args ([a0a53f3](https://github.com/eliotstocker/Brsh-JS/commit/a0a53f3f2f31179a63059860a54f18a3c905755b))
|
|
7
|
+
|
|
1
8
|
## [3.10.1](https://github.com/eliotstocker/Brsh-JS/compare/v3.10.0...v3.10.1) (2026-11-11)
|
|
2
9
|
|
|
3
10
|
|
package/dist/shell.es.js
CHANGED
|
@@ -1497,16 +1497,28 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
|
|
|
1497
1497
|
return t;
|
|
1498
1498
|
}
|
|
1499
1499
|
run() {
|
|
1500
|
-
let e =
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1500
|
+
let e = parseInt(r.sandbox.context.getVar("#") || "0", 10) || 0, t = Math.max(e, this.arguments.length), i = [];
|
|
1501
|
+
for (let e = 1; e <= t; e++) {
|
|
1502
|
+
let t = String(e);
|
|
1503
|
+
i.push({
|
|
1504
|
+
key: t,
|
|
1505
|
+
prev: r.sandbox.context.getVar(t)
|
|
1506
|
+
}), e <= this.arguments.length ? r.sandbox.context.setVar(t, this.arguments[e - 1]) : r.sandbox.context.unsetVar(t);
|
|
1507
|
+
}
|
|
1508
|
+
for (let e of [
|
|
1509
|
+
"#",
|
|
1510
|
+
"@",
|
|
1511
|
+
"*"
|
|
1512
|
+
]) i.push({
|
|
1513
|
+
key: e,
|
|
1514
|
+
prev: r.sandbox.context.getVar(e)
|
|
1515
|
+
});
|
|
1516
|
+
r.sandbox.context.setVar("#", String(this.arguments.length)), r.sandbox.context.setVar("@", this.arguments.join(" ")), r.sandbox.context.setVar("*", this.arguments.join(" "));
|
|
1517
|
+
let a = () => i.forEach(({ key: e, prev: t }) => t ? r.sandbox.context.setVar(e, t) : r.sandbox.context.unsetVar(e));
|
|
1506
1518
|
return r._executeFunctionBody(n).then(() => {
|
|
1507
|
-
|
|
1519
|
+
a();
|
|
1508
1520
|
}).catch((e) => {
|
|
1509
|
-
if (
|
|
1521
|
+
if (a(), e && e.__type === "return") {
|
|
1510
1522
|
this.exitCode = e.code;
|
|
1511
1523
|
return;
|
|
1512
1524
|
}
|
|
@@ -9360,11 +9372,32 @@ var V, H, ne, U, re, ie, W, G, K, q, J = e((() => {
|
|
|
9360
9372
|
throw Error(`${e}: Command not found`);
|
|
9361
9373
|
}
|
|
9362
9374
|
async _parseCommandLine(t) {
|
|
9363
|
-
let n = e._splitCommand(t);
|
|
9364
|
-
|
|
9365
|
-
value: e
|
|
9366
|
-
|
|
9367
|
-
|
|
9375
|
+
let n = e._splitCommand(t), r = n.length > 0 ? n[0].value : "", i = r === "export" || r === "alias" || r === "local", a = [];
|
|
9376
|
+
for (let e = 0; e < n.length; e++) {
|
|
9377
|
+
let { value: t, hasQuote: r } = n[e];
|
|
9378
|
+
if (r && t === "$@") {
|
|
9379
|
+
let e = parseInt(this.context.getVar("#") || "0", 10) || 0;
|
|
9380
|
+
for (let t = 1; t <= e; t++) a.push({
|
|
9381
|
+
value: String(this.context.getVar(String(t))),
|
|
9382
|
+
hasQuote: !0
|
|
9383
|
+
});
|
|
9384
|
+
continue;
|
|
9385
|
+
}
|
|
9386
|
+
let o = await this._replaceVariables(t), s = n.length === 1 && /^[A-Za-z_]\w*=/.test(t), c = e > 0 && i && /^[A-Za-z_]\w*=/.test(t);
|
|
9387
|
+
if (r || s || c || !t.includes("$")) {
|
|
9388
|
+
(o.length > 0 || r) && a.push({
|
|
9389
|
+
value: o,
|
|
9390
|
+
hasQuote: r
|
|
9391
|
+
});
|
|
9392
|
+
continue;
|
|
9393
|
+
}
|
|
9394
|
+
let l = o.trim().split(/\s+/).filter(Boolean);
|
|
9395
|
+
for (let e of l) a.push({
|
|
9396
|
+
value: e,
|
|
9397
|
+
hasQuote: !1
|
|
9398
|
+
});
|
|
9399
|
+
}
|
|
9400
|
+
return a;
|
|
9368
9401
|
}
|
|
9369
9402
|
static _sanitiseCommandPart(e) {
|
|
9370
9403
|
return e.startsWith("\"") && e.endsWith("\"") || e.startsWith("'") && e.endsWith("'") ? e.substring(1, e.length - 1) : e;
|