brsh 3.1.0 → 3.1.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,17 @@
1
+ ## [3.1.2](https://github.com/eliotstocker/Brsh-JS/compare/v3.1.1...v3.1.2) (2026-11-08)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **wasm:** fallback to this.fs when context.fs is not present on readonlyContext ([6cdd2da](https://github.com/eliotstocker/Brsh-JS/commit/6cdd2da210203b91ad53b5f7653d7f3764eda85f))
7
+
8
+ ## [3.1.1](https://github.com/eliotstocker/Brsh-JS/compare/v3.1.0...v3.1.1) (2026-11-08)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **shell:** handle backslash quote escaping in _splitCommand ([692cc9c](https://github.com/eliotstocker/Brsh-JS/commit/692cc9c2852b5ed2b2ae94e9e7a1b3cacce9ada9))
14
+
1
15
  # [3.1.0](https://github.com/eliotstocker/Brsh-JS/compare/v3.0.0...v3.1.0) (2026-11-08)
2
16
 
3
17
 
package/dist/shell.es.js CHANGED
@@ -2309,26 +2309,26 @@ var j, M, N, P, F, I, L, R, z, B, V = e((() => {
2309
2309
  this.sandbox && this.sandbox.onInput(e);
2310
2310
  }
2311
2311
  run() {
2312
- let e = this.context.fs.isRealFilesystem ? { useRealFilesystem: !0 } : {
2313
- filesystem: this.context.fs.getRaw(),
2314
- permissions: this.context.fs.getRawPermissions()
2312
+ let e = this.context && this.context.fs || this.fs, t = e && e.isRealFilesystem ? { useRealFilesystem: !0 } : {
2313
+ filesystem: e && e.getRaw() || {},
2314
+ permissions: e && e.getRawPermissions() || {}
2315
2315
  };
2316
2316
  this.sandbox = new globalThis.shell({
2317
- cwd: this.context.fs.cwd,
2318
- ...e,
2317
+ cwd: e && e.cwd || "/",
2318
+ ...t,
2319
2319
  subshell: !0
2320
2320
  }), this.sandbox.context.source(this.context), this.sandbox.on("stdOut", (e) => {
2321
2321
  this.stdOut = e, this.flush();
2322
2322
  }), this.sandbox.on("stdErr", (e) => {
2323
2323
  this.stdErr = e, this.flush();
2324
2324
  }), this._scriptFunctions = {};
2325
- let t = this.script.split(/\r?\n/);
2326
- if (!r(t[0])) {
2327
- let e = t[0].startsWith("#!") ? t[0].slice(2).split(/\s/)[0] : t[0];
2325
+ let n = this.script.split(/\r?\n/);
2326
+ if (!r(n[0])) {
2327
+ let e = n[0].startsWith("#!") ? n[0].slice(2).split(/\s/)[0] : n[0];
2328
2328
  return Promise.reject(`${e}: bad interpreter: No such file or directory`);
2329
2329
  }
2330
- let n = this._parseLines(t.slice(1));
2331
- return this._executeNodes(n).catch((e) => {
2330
+ let i = this._parseLines(n.slice(1));
2331
+ return this._executeNodes(i).catch((e) => {
2332
2332
  if (e && e.__type === "return") this.sandbox.lastCode = e.code;
2333
2333
  else if (e && e.__type === "errexit") this.sandbox.lastCode = e.code;
2334
2334
  else if (e && (e.__type === "break" || e.__type === "continue")) this.stdErr = `${e.__type}: only meaningful in a for or while loop`, this.sandbox.lastCode = 1;
@@ -2681,21 +2681,23 @@ var j, M, N, P, F, I, L, R, z, B, V = e((() => {
2681
2681
  });
2682
2682
  }
2683
2683
  _loadBytes(e, t) {
2684
- if (this.context.fs.isRealFilesystem && t) try {
2685
- let n = t.readFileSync(this.context.fs.absolutePath(e)), r = new Uint8Array(n);
2684
+ let n = this.context && this.context.fs || this.fs;
2685
+ if (!n) return Promise.reject(/* @__PURE__ */ Error(`${e}: Filesystem is not available`));
2686
+ if (n.isRealFilesystem && t) try {
2687
+ let r = t.readFileSync(n.absolutePath(e)), i = new Uint8Array(r);
2686
2688
  return Promise.resolve({
2687
- bytes: r,
2688
- isWat: this._isWat(e, r)
2689
+ bytes: i,
2690
+ isWat: this._isWat(e, i)
2689
2691
  });
2690
2692
  } catch (t) {
2691
2693
  return Promise.reject(/* @__PURE__ */ Error(`${e}: ${t.message}`));
2692
2694
  }
2693
- let n = this.context.fs.getFileByPath(e);
2694
- if (n == null) return Promise.reject(/* @__PURE__ */ Error(`${e}: No such file or directory`));
2695
- let r = this._contentToBytes(n);
2695
+ let r = n.getFileByPath(e);
2696
+ if (r == null) return Promise.reject(/* @__PURE__ */ Error(`${e}: No such file or directory`));
2697
+ let i = this._contentToBytes(r);
2696
2698
  return Promise.resolve({
2697
- bytes: r,
2698
- isWat: this._isWat(e, r)
2699
+ bytes: i,
2700
+ isWat: this._isWat(e, i)
2699
2701
  });
2700
2702
  }
2701
2703
  _isWat(e, t) {
@@ -8294,6 +8296,18 @@ var j, M, N, P, F, I, L, R, z, B, V = e((() => {
8294
8296
  a.push(l), l === "(" ? i++ : l === ")" && i--;
8295
8297
  continue;
8296
8298
  }
8299
+ if (r && l === "\\" && c + 1 < e.length) {
8300
+ let t = e[c + 1];
8301
+ if (t === "\"" || t === "\\" || t === "$") {
8302
+ a.push(t), c++;
8303
+ continue;
8304
+ }
8305
+ }
8306
+ if (!n && !r && l === "\\" && c + 1 < e.length) {
8307
+ let t = e[++c];
8308
+ a.push(t), (t === "\"" || t === "'") && (o = !0);
8309
+ continue;
8310
+ }
8297
8311
  if (l === "'" && !r) {
8298
8312
  n = !n, o = !0;
8299
8313
  continue;