brsh 3.10.5 → 3.10.6

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.6](https://github.com/eliotstocker/Brsh-JS/compare/v3.10.5...v3.10.6) (2026-11-28)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **read:** add -r, backslash handling, multiple names and IFS splitting ([87235c1](https://github.com/eliotstocker/Brsh-JS/commit/87235c1c065481defa0bf5ca0973994c34106af6))
7
+
1
8
  ## [3.10.5](https://github.com/eliotstocker/Brsh-JS/compare/v3.10.4...v3.10.5) (2026-11-27)
2
9
 
3
10
 
package/dist/shell.es.js CHANGED
@@ -6566,7 +6566,7 @@ var B, V, re, H, ie, ae, U, W, G, K, q = e((() => {
6566
6566
  } catch (e) {
6567
6567
  return this.printHelp(e), Promise.reject();
6568
6568
  }
6569
- return e.help ? (this.printHelp(), Promise.resolve()) : (this.nchars = e.nchars, this.var = e.name, new Promise((t) => {
6569
+ return e.help ? (this.printHelp(), Promise.resolve()) : (this.nchars = e.nchars, this.names = e.name || [], this.raw = e.raw, new Promise((t) => {
6570
6570
  let n = setTimeout(() => {
6571
6571
  t(), this.exitCode = 1;
6572
6572
  }, e.timeout ? e.timeout * 1e3 : 864e5);
@@ -6576,20 +6576,32 @@ var B, V, re, H, ie, ae, U, W, G, K, q = e((() => {
6576
6576
  }));
6577
6577
  }
6578
6578
  onInput(e) {
6579
- if (this.inputBuffer ||= "", e.length === 1 && (this.inputBuffer += e), e === "Enter") {
6580
- this.var ? (this.context.setVar(this.var, this.inputBuffer || ""), this.completionCallback()) : this.completionCallback(this.inputBuffer || "");
6579
+ if (this.inputBuffer ||= "", !this.raw && !this.escaped && e === "\\") {
6580
+ this.escaped = !0;
6581
6581
  return;
6582
6582
  }
6583
- if (this.inputBuffer.length === this.nchars) {
6584
- if (this.var) {
6585
- this.context.setVar(this.var, this.inputBuffer), this.completionCallback();
6586
- return;
6583
+ this.escaped && (delete this.escaped, e === "Enter") || e.length === 1 && (this.inputBuffer += e, this.inputBuffer.length !== this.nchars) || (e === "Enter" || this.inputBuffer.length === this.nchars) && this._finish();
6584
+ }
6585
+ _finish() {
6586
+ if (this.names.length < 1) return this.completionCallback(this.inputBuffer);
6587
+ let e = this.context.vars.IFS;
6588
+ this._split(this.inputBuffer, e === void 0 ? " \n" : e).forEach((e, t) => this.context.setVar(this.names[t], e)), this.completionCallback();
6589
+ }
6590
+ _split(e, t) {
6591
+ let { names: n } = this, r = (e) => e.replace(/[\]\\^-]/g, "\\$&"), i = r(t.replace(/[^ \t\n]/g, "")), a = r(t.replace(/[ \t\n]/g, "")), o = (e) => i ? e.replace(RegExp(`^[${i}]+`), "") : e, s = (e) => i ? e.replace(RegExp(`[${i}]+$`), "") : e, c = t === "" ? null : RegExp(a ? `[${i}]*[${a}][${i}]*|[${i}]+` : `[${i}]+`), l = o(e);
6592
+ return n.map((e, t) => {
6593
+ if (t === n.length - 1) return s(l);
6594
+ let r = c && c.exec(l);
6595
+ if (!r) {
6596
+ let e = l;
6597
+ return l = "", e;
6587
6598
  }
6588
- this.completionCallback(this.inputBuffer);
6589
- }
6599
+ let i = l.slice(0, r.index);
6600
+ return l = l.slice(r.index + r[0].length), i;
6601
+ });
6590
6602
  }
6591
6603
  printHelp(e) {
6592
- e && (this.stdOut = e.message), this.stdOut = "usage: read [-n nchars] [-p prompt] [-t timeout] [name ...]";
6604
+ e && (this.stdOut = e.message), this.stdOut = "usage: read [-r] [-n nchars] [-p prompt] [-t timeout] [name ...]";
6593
6605
  }
6594
6606
  parseArgs() {
6595
6607
  return r([
@@ -6608,6 +6620,11 @@ var B, V, re, H, ie, ae, U, W, G, K, q = e((() => {
6608
6620
  alias: "t",
6609
6621
  type: Number
6610
6622
  },
6623
+ {
6624
+ name: "raw",
6625
+ alias: "r",
6626
+ type: Boolean
6627
+ },
6611
6628
  {
6612
6629
  name: "help",
6613
6630
  alias: "h",
@@ -6615,6 +6632,7 @@ var B, V, re, H, ie, ae, U, W, G, K, q = e((() => {
6615
6632
  },
6616
6633
  {
6617
6634
  defaultOption: !0,
6635
+ multiple: !0,
6618
6636
  name: "name",
6619
6637
  type: String
6620
6638
  }