brsh 3.2.0 → 3.3.0
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/POSIX-CHECKLIST.md +3 -0
- package/dist/shell.es.js +279 -43
- package/dist/shell.es.js.map +1 -1
- package/dist/shell.min.js +8 -8
- package/dist/shell.min.js.map +1 -1
- package/dist/wbt.es.js +275 -167
- package/dist/wbt.es.js.map +1 -1
- package/dist/wbt.min.js +8 -3
- package/dist/wbt.min.js.map +1 -1
- package/index.js +285 -57
- package/lib/ReplCommand.js +21 -1
- package/lib/ScriptCommand.js +101 -0
- package/lib/wbt/packages/wllama.js +240 -15
- package/package.json +1 -1
- package/test/scripts.test.js +80 -0
- package/test/shell.test.js +115 -0
- package/test/wbt.test.js +92 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [3.3.0](https://github.com/eliotstocker/Brsh-JS/compare/v3.2.0...v3.3.0) (2026-11-09)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* stream tokens and show lifecycle status in wllama; add posix redirection and multiline script support ([238b9a3](https://github.com/eliotstocker/Brsh-JS/commit/238b9a33c7f476cad975cee135cd3e89696f708c))
|
|
7
|
+
|
|
1
8
|
# [3.2.0](https://github.com/eliotstocker/Brsh-JS/compare/v3.1.4...v3.2.0) (2026-11-09)
|
|
2
9
|
|
|
3
10
|
|
package/POSIX-CHECKLIST.md
CHANGED
|
@@ -8,10 +8,13 @@ Track progress toward a POSIX-compliant `sh` implementation in Brsh-JS.
|
|
|
8
8
|
|
|
9
9
|
### Operators / Redirection
|
|
10
10
|
- [x] Pipes (`|`) — `cmd1 | cmd2`
|
|
11
|
+
- [x] Negation operator (`!`) — `! cmd` / `! pipeline`
|
|
11
12
|
- [x] Logical AND (`&&`)
|
|
12
13
|
- [x] Logical OR (`||`)
|
|
13
14
|
- [x] Sequential (`;`)
|
|
14
15
|
- [x] Output redirect (`>`, `>>`)
|
|
16
|
+
- [x] Stream & file descriptor redirect (`2>&1`, `2>`, `1>`, `&>`)
|
|
17
|
+
- [x] Line continuation (`\`) and multiline quotes (`'`, `"`) in scripts
|
|
15
18
|
- [ ] Input redirect (`<`)
|
|
16
19
|
- [ ] Here-doc (`<<EOF … EOF`)
|
|
17
20
|
- [ ] Here-string (`<<<`)
|
package/dist/shell.es.js
CHANGED
|
@@ -2337,7 +2337,34 @@ var j, M, N, P, F, I, L, R, z, B, V = e((() => {
|
|
|
2337
2337
|
this.exitCode = this.sandbox.lastCode, this.source && this.context.source(this.sandbox.context);
|
|
2338
2338
|
});
|
|
2339
2339
|
}
|
|
2340
|
+
_accumulateLines(e) {
|
|
2341
|
+
let t = [], n = null, r = !1, i = !1, a = !1;
|
|
2342
|
+
for (let o = 0; o < e.length; o++) {
|
|
2343
|
+
let s = e[o];
|
|
2344
|
+
n === null ? n = s : a ? n += s : r || i ? n += "\n" + s : n += s;
|
|
2345
|
+
let c = 0, l = !1, u = !1;
|
|
2346
|
+
for (; c < s.length;) {
|
|
2347
|
+
let e = s[c];
|
|
2348
|
+
if (r) e === "'" && (r = !1), c++;
|
|
2349
|
+
else if (i) e === "\\" && c + 1 < s.length ? c += 2 : e === "\\" && c + 1 === s.length ? (l = !0, c++) : (e === "\"" && (i = !1), c++);
|
|
2350
|
+
else {
|
|
2351
|
+
if (e === "#" && (c === 0 || /\s/.test(s[c - 1]))) {
|
|
2352
|
+
u = !0;
|
|
2353
|
+
break;
|
|
2354
|
+
}
|
|
2355
|
+
e === "\\" && c + 1 < s.length ? c += 2 : e === "\\" && c + 1 === s.length ? (l = !0, c++) : e === "'" ? (r = !0, c++) : (e === "\"" && (i = !0), c++);
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
if (!r && !l && !u) {
|
|
2359
|
+
let e = s.match(/(\\+)\s*$/);
|
|
2360
|
+
e && e[1].length % 2 == 1 && (l = !0);
|
|
2361
|
+
}
|
|
2362
|
+
a = l, l && (n = n.replace(/\\\s*$/, "")), !r && !i && !l && (t.push(n), n = null, a = !1);
|
|
2363
|
+
}
|
|
2364
|
+
return n !== null && t.push(n), t;
|
|
2365
|
+
}
|
|
2340
2366
|
_parseLines(e) {
|
|
2367
|
+
e = this._accumulateLines(e);
|
|
2341
2368
|
let t = [], n = 0;
|
|
2342
2369
|
for (; n < e.length;) {
|
|
2343
2370
|
let r = e[n].trim();
|
|
@@ -7448,6 +7475,20 @@ var j, M, N, P, F, I, L, R, z, B, V = e((() => {
|
|
|
7448
7475
|
});
|
|
7449
7476
|
this._scrollOffset = 0;
|
|
7450
7477
|
}
|
|
7478
|
+
streamReplChunk(e, t = "out") {
|
|
7479
|
+
if (!e) return;
|
|
7480
|
+
(this._replLog.length === 0 || this._replLog[this._replLog.length - 1].type !== t || !this._replStreamingActive) && (this._replLog.push({
|
|
7481
|
+
text: "",
|
|
7482
|
+
type: t
|
|
7483
|
+
}), this._replStreamingActive = !0);
|
|
7484
|
+
let n = this._replLog[this._replLog.length - 1], r = (n.text + e).split(/\r?\n/);
|
|
7485
|
+
n.text = r[0];
|
|
7486
|
+
for (let e = 1; e < r.length; e++) this._replLog.push({
|
|
7487
|
+
text: r[e],
|
|
7488
|
+
type: t
|
|
7489
|
+
});
|
|
7490
|
+
this._scrollOffset = 0, this._renderRepl();
|
|
7491
|
+
}
|
|
7451
7492
|
onInput(e) {
|
|
7452
7493
|
if (this.shouldBeInteractive()) {
|
|
7453
7494
|
if (e === "^D" || e === "^X") {
|
|
@@ -7481,8 +7522,8 @@ var j, M, N, P, F, I, L, R, z, B, V = e((() => {
|
|
|
7481
7522
|
}
|
|
7482
7523
|
let n = this._dynamicReplBuffer || e;
|
|
7483
7524
|
this._dynamicReplBuffer = "", this._dynamicReplMultiline = !1, this._replBusy = !0, this._replStatus = "Running...", this._renderRepl(), Promise.resolve().then(() => this.evaluateReplLine(n)).then((e) => {
|
|
7484
|
-
if (this._replBusy = !1, this._replStatus = "^D / .exit: Quit | ^L: Clear | Up/Down: History", e) {
|
|
7485
|
-
if (e.clear && (this._replLog = []), Array.isArray(e.output)) for (let t of e.output) this._appendReplLog(t, "out");
|
|
7525
|
+
if (this._replBusy = !1, this._replStreamingActive = !1, this._replStatus = "^D / .exit: Quit | ^L: Clear | Up/Down: History", e) {
|
|
7526
|
+
if (e.clear && (this._replLog = []), !e.streamed) if (Array.isArray(e.output)) for (let t of e.output) this._appendReplLog(t, "out");
|
|
7486
7527
|
else typeof e.output == "string" && e.output.length > 0 && this._appendReplLog(e.output, "out");
|
|
7487
7528
|
if (e.error && this._appendReplLog(e.error, "err"), e.exit) {
|
|
7488
7529
|
this._exitRepl();
|
|
@@ -7861,58 +7902,246 @@ var j, M, N, P, F, I, L, R, z, B, V = e((() => {
|
|
|
7861
7902
|
return;
|
|
7862
7903
|
}
|
|
7863
7904
|
if (!n.length) return;
|
|
7864
|
-
let r =
|
|
7865
|
-
|
|
7866
|
-
|
|
7867
|
-
this.
|
|
7905
|
+
let r = !1;
|
|
7906
|
+
for (; n.length > 0 && !n[0].hasQuote && n[0].value === "!";) r = !r, n.shift();
|
|
7907
|
+
if (!n.length) {
|
|
7908
|
+
this.lastCode = +!!r, this.emit("exitCode", this.lastCode);
|
|
7868
7909
|
return;
|
|
7869
7910
|
}
|
|
7870
|
-
let o =
|
|
7911
|
+
let o = { type: "stdout" }, s = { type: "stderr" }, c = [];
|
|
7871
7912
|
for (let e = 0; e < n.length; e++) {
|
|
7872
7913
|
let { value: t, hasQuote: r } = n[e];
|
|
7873
|
-
|
|
7914
|
+
if (r) {
|
|
7915
|
+
c.push(t);
|
|
7916
|
+
continue;
|
|
7917
|
+
}
|
|
7918
|
+
if (t === "2>&1") {
|
|
7919
|
+
s = { ...o };
|
|
7920
|
+
continue;
|
|
7921
|
+
}
|
|
7922
|
+
if (t === "1>&2") {
|
|
7923
|
+
o = { ...s };
|
|
7924
|
+
continue;
|
|
7925
|
+
}
|
|
7926
|
+
if (t === "2>&-") {
|
|
7927
|
+
s = { type: "null" };
|
|
7928
|
+
continue;
|
|
7929
|
+
}
|
|
7930
|
+
if (t === "1>&-" || t === ">&-") {
|
|
7931
|
+
o = { type: "null" };
|
|
7932
|
+
continue;
|
|
7933
|
+
}
|
|
7934
|
+
if (t === "&>>") {
|
|
7935
|
+
if (e + 1 < n.length) {
|
|
7936
|
+
let t = n[++e].value, r = t === "/dev/null" ? { type: "null" } : {
|
|
7937
|
+
type: "file",
|
|
7938
|
+
file: t,
|
|
7939
|
+
append: !0
|
|
7940
|
+
};
|
|
7941
|
+
o = r, s = r;
|
|
7942
|
+
}
|
|
7943
|
+
continue;
|
|
7944
|
+
}
|
|
7945
|
+
if (t === "&>" || t === ">&") {
|
|
7946
|
+
if (e + 1 < n.length) {
|
|
7947
|
+
let t = n[++e].value, r = t === "/dev/null" ? { type: "null" } : {
|
|
7948
|
+
type: "file",
|
|
7949
|
+
file: t,
|
|
7950
|
+
append: !1
|
|
7951
|
+
};
|
|
7952
|
+
o = r, s = r;
|
|
7953
|
+
}
|
|
7954
|
+
continue;
|
|
7955
|
+
}
|
|
7956
|
+
if (t.startsWith("&>>") && t.length > 3) {
|
|
7957
|
+
let e = t.slice(3), n = e === "/dev/null" ? { type: "null" } : {
|
|
7958
|
+
type: "file",
|
|
7959
|
+
file: e,
|
|
7960
|
+
append: !0
|
|
7961
|
+
};
|
|
7962
|
+
o = n, s = n;
|
|
7963
|
+
continue;
|
|
7964
|
+
}
|
|
7965
|
+
if ((t.startsWith("&>") || t.startsWith(">&")) && t.length > 2) {
|
|
7966
|
+
let e = t.slice(2), n = e === "/dev/null" ? { type: "null" } : {
|
|
7967
|
+
type: "file",
|
|
7968
|
+
file: e,
|
|
7969
|
+
append: !1
|
|
7970
|
+
};
|
|
7971
|
+
o = n, s = n;
|
|
7972
|
+
continue;
|
|
7973
|
+
}
|
|
7974
|
+
if (t === "2>>") {
|
|
7975
|
+
if (e + 1 < n.length) {
|
|
7976
|
+
let t = n[++e].value;
|
|
7977
|
+
s = t === "/dev/null" ? { type: "null" } : {
|
|
7978
|
+
type: "file",
|
|
7979
|
+
file: t,
|
|
7980
|
+
append: !0
|
|
7981
|
+
};
|
|
7982
|
+
}
|
|
7983
|
+
continue;
|
|
7984
|
+
}
|
|
7985
|
+
if (t === "2>") {
|
|
7986
|
+
if (e + 1 < n.length) {
|
|
7987
|
+
let t = n[++e].value;
|
|
7988
|
+
s = t === "/dev/null" ? { type: "null" } : {
|
|
7989
|
+
type: "file",
|
|
7990
|
+
file: t,
|
|
7991
|
+
append: !1
|
|
7992
|
+
};
|
|
7993
|
+
}
|
|
7994
|
+
continue;
|
|
7995
|
+
}
|
|
7996
|
+
if (t.startsWith("2>>") && t.length > 3) {
|
|
7997
|
+
let e = t.slice(3);
|
|
7998
|
+
s = e === "/dev/null" ? { type: "null" } : {
|
|
7999
|
+
type: "file",
|
|
8000
|
+
file: e,
|
|
8001
|
+
append: !0
|
|
8002
|
+
};
|
|
8003
|
+
continue;
|
|
8004
|
+
}
|
|
8005
|
+
if (t.startsWith("2>") && t.length > 2) {
|
|
8006
|
+
let e = t.slice(2);
|
|
8007
|
+
s = e === "/dev/null" ? { type: "null" } : {
|
|
8008
|
+
type: "file",
|
|
8009
|
+
file: e,
|
|
8010
|
+
append: !1
|
|
8011
|
+
};
|
|
8012
|
+
continue;
|
|
8013
|
+
}
|
|
8014
|
+
if (t === "1>>" || t === ">>") {
|
|
8015
|
+
if (e + 1 < n.length) {
|
|
8016
|
+
let t = n[++e].value;
|
|
8017
|
+
o = t === "/dev/null" ? { type: "null" } : {
|
|
8018
|
+
type: "file",
|
|
8019
|
+
file: t,
|
|
8020
|
+
append: !0
|
|
8021
|
+
};
|
|
8022
|
+
}
|
|
8023
|
+
continue;
|
|
8024
|
+
}
|
|
8025
|
+
if (t === "1>" || t === ">") {
|
|
8026
|
+
if (e + 1 < n.length) {
|
|
8027
|
+
let t = n[++e].value;
|
|
8028
|
+
o = t === "/dev/null" ? { type: "null" } : {
|
|
8029
|
+
type: "file",
|
|
8030
|
+
file: t,
|
|
8031
|
+
append: !1
|
|
8032
|
+
};
|
|
8033
|
+
}
|
|
8034
|
+
continue;
|
|
8035
|
+
}
|
|
8036
|
+
if ((t.startsWith("1>>") || t.startsWith(">>")) && t.length > (t.startsWith("1>>") ? 3 : 2)) {
|
|
8037
|
+
let e = t.slice(t.startsWith("1>>") ? 3 : 2);
|
|
8038
|
+
o = e === "/dev/null" ? { type: "null" } : {
|
|
8039
|
+
type: "file",
|
|
8040
|
+
file: e,
|
|
8041
|
+
append: !0
|
|
8042
|
+
};
|
|
8043
|
+
continue;
|
|
8044
|
+
}
|
|
8045
|
+
if ((t.startsWith("1>") || t.startsWith(">")) && t.length > (t.startsWith("1>") ? 2 : 1)) {
|
|
8046
|
+
let e = t.slice(t.startsWith("1>") ? 2 : 1);
|
|
8047
|
+
o = e === "/dev/null" ? { type: "null" } : {
|
|
8048
|
+
type: "file",
|
|
8049
|
+
file: e,
|
|
8050
|
+
append: !1
|
|
8051
|
+
};
|
|
8052
|
+
continue;
|
|
8053
|
+
}
|
|
8054
|
+
c.push(t);
|
|
8055
|
+
}
|
|
8056
|
+
if (!c.length) {
|
|
8057
|
+
for (let e of [o, s]) if (e.type === "file" && e.file !== "/dev/null") try {
|
|
8058
|
+
let t = this.context.fs.absolutePath(e.file), n = this.context.fs._getFileRaw(t);
|
|
8059
|
+
(!e.append || n === void 0) && this.context.fs.setFileByPath(t, n || "", !0);
|
|
8060
|
+
} catch {
|
|
8061
|
+
this.emit("stdErr", `${e.file}: Permission denied`), this.lastCode = +!r, this.emit("exitCode", this.lastCode);
|
|
8062
|
+
return;
|
|
8063
|
+
}
|
|
8064
|
+
this.lastCode = +!!r, this.emit("exitCode", this.lastCode);
|
|
8065
|
+
return;
|
|
8066
|
+
}
|
|
8067
|
+
let l = c.shift();
|
|
8068
|
+
if (n = c, n.length === 0 && /^[A-Za-z_]\w*=/.test(l)) {
|
|
8069
|
+
let e = l.indexOf("=");
|
|
8070
|
+
this.context.setVar(l.slice(0, e), l.slice(e + 1)), this.lastCode = +!!r, this.emit("exitCode", this.lastCode);
|
|
8071
|
+
return;
|
|
7874
8072
|
}
|
|
7875
|
-
|
|
7876
|
-
|
|
7877
|
-
|
|
7878
|
-
|
|
8073
|
+
let u = this.context.getAlias(l);
|
|
8074
|
+
if (u) return this.onCommand(u, !1).then(() => {
|
|
8075
|
+
r && (this.lastCode = +(this.lastCode === 0), this.emit("exitCode", this.lastCode));
|
|
8076
|
+
});
|
|
8077
|
+
let d;
|
|
7879
8078
|
try {
|
|
7880
|
-
|
|
8079
|
+
d = this._parseCommand(l.startsWith("/") || l.startsWith("./") ? l : l.toLowerCase());
|
|
7881
8080
|
} catch (e) {
|
|
7882
|
-
this.
|
|
8081
|
+
this._handleCommandError(e.message, s, r);
|
|
7883
8082
|
return;
|
|
7884
8083
|
}
|
|
7885
|
-
let
|
|
7886
|
-
if (
|
|
7887
|
-
else if (d
|
|
8084
|
+
let f = (e) => typeof e == "function" && typeof e.prototype.run == "function" && typeof e.prototype.runCommand == "function", p;
|
|
8085
|
+
if (d.prototype instanceof i || new d() instanceof a) p = new d(n, this.context);
|
|
8086
|
+
else if (f(d)) p = new d(n, this._readonlyContext);
|
|
7888
8087
|
else {
|
|
7889
|
-
this.
|
|
8088
|
+
this._handleCommandError(`${l}: Command not found`, s, r);
|
|
7890
8089
|
return;
|
|
7891
8090
|
}
|
|
7892
|
-
|
|
7893
|
-
|
|
8091
|
+
p.requiresFilesystem && (p.fs = this.context.fs.sandbox()), this._stdin !== void 0 && (p.stdin = this._stdin);
|
|
8092
|
+
let m = /* @__PURE__ */ new Map(), h = ({ type: e, string: t }) => {
|
|
8093
|
+
let n = e === "out" ? o : s;
|
|
8094
|
+
if (n.type === "stdout") this.emit("stdOut", t);
|
|
8095
|
+
else if (n.type === "stderr") this.emit("stdErr", t);
|
|
8096
|
+
else if (n.type === "file" && n.file !== "/dev/null") {
|
|
8097
|
+
let e = m.get(n.file);
|
|
8098
|
+
e || (e = {
|
|
8099
|
+
append: n.append,
|
|
8100
|
+
lines: []
|
|
8101
|
+
}, m.set(n.file, e)), e.lines.push(t);
|
|
8102
|
+
}
|
|
8103
|
+
};
|
|
8104
|
+
return this.runningCommand = p, this.runningCommand.on && (this.runningCommand.on("flush", (e) => {
|
|
8105
|
+
e.forEach(h);
|
|
7894
8106
|
}), this.runningCommand.on("stdout", (e) => {
|
|
7895
|
-
o ?
|
|
8107
|
+
o.type === "file" ? p._streamedStdout || (p.stdOut = String(e ?? "")) : o.type === "stderr" ? this.stderr.write(e) : o.type === "null" || (this.stdout.write(e), this.emit("stdOutRaw", e));
|
|
8108
|
+
}), this.runningCommand.on("token", (e) => {
|
|
8109
|
+
this.emit("token", e);
|
|
7896
8110
|
}), this.runningCommand.on("stderr", (e) => {
|
|
7897
|
-
this.stderr.write(e);
|
|
7898
|
-
})),
|
|
7899
|
-
|
|
7900
|
-
|
|
7901
|
-
|
|
7902
|
-
|
|
7903
|
-
|
|
7904
|
-
|
|
8111
|
+
s.type === "file" ? p.stdErr = String(e ?? "") : s.type === "stdout" ? o.type === "file" ? p.stdOut = String(e ?? "") : o.type === "null" || (this.stdout.write(e), this.emit("stdOutRaw", e)) : s.type === "null" || this.stderr.write(e);
|
|
8112
|
+
})), p.interactive && this.emit("interactive"), p.runCommand().then((e) => {
|
|
8113
|
+
e.getStdOutput().forEach(h);
|
|
8114
|
+
for (let e of [o, s]) e.type === "file" && e.file !== "/dev/null" && !m.has(e.file) && m.set(e.file, {
|
|
8115
|
+
append: e.append,
|
|
8116
|
+
lines: []
|
|
8117
|
+
});
|
|
8118
|
+
for (let [e, { append: t, lines: n }] of m) {
|
|
8119
|
+
let i = this.context.fs.absolutePath(e), a = n.join("\n"), o = a;
|
|
8120
|
+
if (t) {
|
|
8121
|
+
let e = this.context.fs._getFileRaw(i);
|
|
8122
|
+
o = typeof e == "string" && e.length > 0 ? e + "\n" + a : a;
|
|
8123
|
+
}
|
|
7905
8124
|
try {
|
|
7906
|
-
this.context.fs.setFileByPath(
|
|
8125
|
+
this.context.fs.setFileByPath(i, o, !0);
|
|
7907
8126
|
} catch {
|
|
7908
|
-
this.emit("stdErr", `${
|
|
8127
|
+
this.emit("stdErr", `${e}: Permission denied`), this.lastCode = +!r, this.emit("exitCode", this.lastCode), delete this.runningCommand;
|
|
7909
8128
|
return;
|
|
7910
8129
|
}
|
|
7911
|
-
|
|
7912
|
-
|
|
7913
|
-
this.lastCode =
|
|
8130
|
+
}
|
|
8131
|
+
let t = e.getExitCode();
|
|
8132
|
+
this.lastCode = r ? +(t === 0) : t, this.emit("exitCode", this.lastCode), delete this.runningCommand;
|
|
7914
8133
|
});
|
|
7915
8134
|
}
|
|
8135
|
+
_handleCommandError(e, t, n) {
|
|
8136
|
+
if (t.type === "stdout") this.emit("stdOut", e);
|
|
8137
|
+
else if (t.type === "file") {
|
|
8138
|
+
if (t.file !== "/dev/null") try {
|
|
8139
|
+
let n = this.context.fs.absolutePath(t.file), r = this.context.fs._getFileRaw(n), i = t.append && typeof r == "string" && r.length > 0 ? r + "\n" + e : e;
|
|
8140
|
+
this.context.fs.setFileByPath(n, i, !0);
|
|
8141
|
+
} catch {}
|
|
8142
|
+
} else t.type === "stderr" && this.emit("stdErr", e);
|
|
8143
|
+
this.lastCode = +!n, this.emit("exitCode", this.lastCode);
|
|
8144
|
+
}
|
|
7916
8145
|
_emitOutput(e) {
|
|
7917
8146
|
e.forEach(({ type: e, string: t }) => {
|
|
7918
8147
|
e === "out" ? this.emit("stdOut", t) : e === "err" && this.emit("stdErr", t);
|
|
@@ -7930,8 +8159,8 @@ var j, M, N, P, F, I, L, R, z, B, V = e((() => {
|
|
|
7930
8159
|
}
|
|
7931
8160
|
_setupTtyStreams() {
|
|
7932
8161
|
this.on("stdOut", (e) => {
|
|
7933
|
-
if (this.runningCommand && (this.runningCommand.interactive || this.runningCommand._inAltScreen)) {
|
|
7934
|
-
this.stdout.write(String(e ?? ""));
|
|
8162
|
+
if (this.runningCommand && (this.runningCommand.interactive || this.runningCommand._inAltScreen || this.runningCommand._streamedStdout)) {
|
|
8163
|
+
(this.runningCommand.interactive || this.runningCommand._inAltScreen) && this.stdout.write(String(e ?? ""));
|
|
7935
8164
|
return;
|
|
7936
8165
|
}
|
|
7937
8166
|
if (typeof e == "string" && e.startsWith("\r")) {
|
|
@@ -8270,17 +8499,24 @@ var j, M, N, P, F, I, L, R, z, B, V = e((() => {
|
|
|
8270
8499
|
op: null
|
|
8271
8500
|
}), t;
|
|
8272
8501
|
}
|
|
8273
|
-
async _runPipeChain(
|
|
8274
|
-
if (
|
|
8275
|
-
let
|
|
8276
|
-
|
|
8277
|
-
t
|
|
8502
|
+
async _runPipeChain(t) {
|
|
8503
|
+
if (t.length === 1) return this._runCommand(t[0]);
|
|
8504
|
+
let n = !1;
|
|
8505
|
+
try {
|
|
8506
|
+
let r = e._splitCommand(t[0]), i = t[0], a = !1;
|
|
8507
|
+
for (; r.length > 0 && !r[0].hasQuote && r[0].value === "!";) n = !n, a = !0, r.shift(), i = i.replace(/^\s*!\s*/, "");
|
|
8508
|
+
a && (t = [i, ...t.slice(1)]);
|
|
8509
|
+
} catch {}
|
|
8510
|
+
let r;
|
|
8511
|
+
for (let e = 0; e < t.length; e++) if (e === t.length - 1) {
|
|
8512
|
+
r !== void 0 && (this._stdin = r);
|
|
8278
8513
|
try {
|
|
8279
|
-
await this._runCommand(e
|
|
8514
|
+
await this._runCommand(t[e]);
|
|
8280
8515
|
} finally {
|
|
8281
8516
|
delete this._stdin;
|
|
8282
8517
|
}
|
|
8283
|
-
} else
|
|
8518
|
+
} else r = await this._captureForPipe(t[e], r);
|
|
8519
|
+
n && (this.lastCode = +(this.lastCode === 0), this.emit("exitCode", this.lastCode));
|
|
8284
8520
|
}
|
|
8285
8521
|
async _captureForPipe(e, t) {
|
|
8286
8522
|
let n = new globalThis.shell({
|