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 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 = this.arguments.map((e, t) => ({
1501
- key: String(t + 1),
1502
- prev: r.sandbox.context.getVar(String(t + 1))
1503
- }));
1504
- this.arguments.forEach((e, t) => r.sandbox.context.setVar(String(t + 1), e));
1505
- let t = () => e.forEach(({ key: e, prev: t }) => t ? r.sandbox.context.setVar(e, t) : r.sandbox.context.unsetVar(e));
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
- t();
1519
+ a();
1508
1520
  }).catch((e) => {
1509
- if (t(), e && e.__type === "return") {
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
- return (await Promise.all(n.map(({ value: e, hasQuote: t }) => this._replaceVariables(e).then((e) => ({
9365
- value: e,
9366
- hasQuote: t
9367
- }))))).filter(({ value: e, hasQuote: t }) => e.length > 0 || t);
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;