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/dist/wbt.es.js CHANGED
@@ -1750,16 +1750,28 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
1750
1750
  return t;
1751
1751
  }
1752
1752
  run() {
1753
- let e = this.arguments.map((e, t) => ({
1754
- key: String(t + 1),
1755
- prev: r.sandbox.context.getVar(String(t + 1))
1756
- }));
1757
- this.arguments.forEach((e, t) => r.sandbox.context.setVar(String(t + 1), e));
1758
- let t = () => e.forEach(({ key: e, prev: t }) => t ? r.sandbox.context.setVar(e, t) : r.sandbox.context.unsetVar(e));
1753
+ let e = parseInt(r.sandbox.context.getVar("#") || "0", 10) || 0, t = Math.max(e, this.arguments.length), i = [];
1754
+ for (let e = 1; e <= t; e++) {
1755
+ let t = String(e);
1756
+ i.push({
1757
+ key: t,
1758
+ prev: r.sandbox.context.getVar(t)
1759
+ }), e <= this.arguments.length ? r.sandbox.context.setVar(t, this.arguments[e - 1]) : r.sandbox.context.unsetVar(t);
1760
+ }
1761
+ for (let e of [
1762
+ "#",
1763
+ "@",
1764
+ "*"
1765
+ ]) i.push({
1766
+ key: e,
1767
+ prev: r.sandbox.context.getVar(e)
1768
+ });
1769
+ r.sandbox.context.setVar("#", String(this.arguments.length)), r.sandbox.context.setVar("@", this.arguments.join(" ")), r.sandbox.context.setVar("*", this.arguments.join(" "));
1770
+ let a = () => i.forEach(({ key: e, prev: t }) => t ? r.sandbox.context.setVar(e, t) : r.sandbox.context.unsetVar(e));
1759
1771
  return r._executeFunctionBody(n).then(() => {
1760
- t();
1772
+ a();
1761
1773
  }).catch((e) => {
1762
- if (t(), e && e.__type === "return") {
1774
+ if (a(), e && e.__type === "return") {
1763
1775
  this.exitCode = e.code;
1764
1776
  return;
1765
1777
  }