@lifo-sh/core 0.2.0 → 0.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.
Files changed (106) hide show
  1. package/dist/awk-B6L8oRkp.js +123 -0
  2. package/dist/{basename-C2v8jn7p.js → basename-CgA_lsvv.js} +1 -1
  3. package/dist/{cat-B2exoWlk.js → cat-UKg6GIpI.js} +1 -1
  4. package/dist/{chmod-CQS63aP7.js → chmod-DHB58pfa.js} +1 -1
  5. package/dist/{chown-rgGwZwu9.js → chown-D1bGwvZd.js} +1 -1
  6. package/dist/commands/registry.d.ts.map +1 -1
  7. package/dist/commands/text/awk.d.ts.map +1 -1
  8. package/dist/commands/text/cut.d.ts.map +1 -1
  9. package/dist/commands/text/diff.d.ts.map +1 -1
  10. package/dist/commands/text/grep.d.ts.map +1 -1
  11. package/dist/commands/text/head.d.ts.map +1 -1
  12. package/dist/commands/text/nl.d.ts.map +1 -1
  13. package/dist/commands/text/rev.d.ts.map +1 -1
  14. package/dist/commands/text/sed.d.ts.map +1 -1
  15. package/dist/commands/text/sort.d.ts.map +1 -1
  16. package/dist/commands/text/tail.d.ts.map +1 -1
  17. package/dist/commands/text/uniq.d.ts.map +1 -1
  18. package/dist/commands/text/wc.d.ts.map +1 -1
  19. package/dist/commands/vcs/git.d.ts +4 -0
  20. package/dist/commands/vcs/git.d.ts.map +1 -0
  21. package/dist/{cp-C8mNek36.js → cp-hsOMjGjb.js} +1 -1
  22. package/dist/cut-BxA2sLod.js +65 -0
  23. package/dist/diff-BgH1-ECz.js +150 -0
  24. package/dist/{dirname-BY_Gu5i2.js → dirname-BsNcj76E.js} +1 -1
  25. package/dist/{du-D25egSeK.js → du-Dz7i5Bf4.js} +1 -1
  26. package/dist/{file-BPs1dqg5.js → file-CiWscEov.js} +1 -1
  27. package/dist/{find-CRUAXbhO.js → find-CWXxOQ3D.js} +1 -1
  28. package/dist/git-mHSHRpnj.js +603 -0
  29. package/dist/{grep-B9pTCSNY.js → grep-BQsxs32R.js} +33 -26
  30. package/dist/gunzip-DF-BdBEb.js +47 -0
  31. package/dist/{gzip-DgE-9PzE.js → gzip-lYiTGRe_.js} +4 -5
  32. package/dist/head-BtcClCUM.js +53 -0
  33. package/dist/{index-DccAPaZF.js → index-Do_xqri5.js} +2574 -1285
  34. package/dist/index.d.ts +9 -1
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +58 -45
  37. package/dist/kernel/index.d.ts +2 -1
  38. package/dist/kernel/index.d.ts.map +1 -1
  39. package/dist/kernel/persistence/PersistenceManager.d.ts +3 -1
  40. package/dist/kernel/persistence/PersistenceManager.d.ts.map +1 -1
  41. package/dist/kernel/persistence/backends.d.ts +22 -0
  42. package/dist/kernel/persistence/backends.d.ts.map +1 -0
  43. package/dist/kernel/persistence/index.d.ts +6 -0
  44. package/dist/kernel/persistence/index.d.ts.map +1 -0
  45. package/dist/kernel/persistence/serializer.d.ts +8 -0
  46. package/dist/kernel/persistence/serializer.d.ts.map +1 -1
  47. package/dist/kernel/storage/BlobStore.d.ts +31 -0
  48. package/dist/kernel/storage/BlobStore.d.ts.map +1 -0
  49. package/dist/kernel/storage/ContentStore.d.ts +52 -0
  50. package/dist/kernel/storage/ContentStore.d.ts.map +1 -0
  51. package/dist/kernel/storage/index.d.ts +7 -0
  52. package/dist/kernel/storage/index.d.ts.map +1 -0
  53. package/dist/kernel/vfs/VFS.d.ts +31 -3
  54. package/dist/kernel/vfs/VFS.d.ts.map +1 -1
  55. package/dist/kernel/vfs/index.d.ts +4 -1
  56. package/dist/kernel/vfs/index.d.ts.map +1 -1
  57. package/dist/kernel/vfs/providers/NativeFsProvider.d.ts +63 -0
  58. package/dist/kernel/vfs/providers/NativeFsProvider.d.ts.map +1 -0
  59. package/dist/kernel/vfs/types.d.ts +27 -0
  60. package/dist/kernel/vfs/types.d.ts.map +1 -1
  61. package/dist/{ls-BiT10kLm.js → ls-BX03h4IP.js} +1 -1
  62. package/dist/{mkdir-DgzJ2JLj.js → mkdir-DGGZuAyh.js} +1 -1
  63. package/dist/{mktemp-Sh5DWxvc.js → mktemp-C537o9DE.js} +1 -1
  64. package/dist/{mv-Kp6DjQ8n.js → mv-46W3dEtX.js} +1 -1
  65. package/dist/{nl-DBLFdpfC.js → nl-vZH6hOSG.js} +13 -10
  66. package/dist/node-compat/buffer.d.ts +29 -2
  67. package/dist/node-compat/buffer.d.ts.map +1 -1
  68. package/dist/node-compat/fs.d.ts +62 -0
  69. package/dist/node-compat/fs.d.ts.map +1 -1
  70. package/dist/{realpath-BOeYN6nD.js → realpath-Ubp4BElh.js} +1 -1
  71. package/dist/rev-Dqg_gF2D.js +39 -0
  72. package/dist/{rm-DA2w3xTR.js → rm-FnbVRwGK.js} +1 -1
  73. package/dist/{rmdir-BiGbNDOT.js → rmdir-B2a-CeUJ.js} +3 -3
  74. package/dist/sandbox/Sandbox.d.ts +31 -0
  75. package/dist/sandbox/Sandbox.d.ts.map +1 -1
  76. package/dist/sandbox/SandboxFs.d.ts +4 -0
  77. package/dist/sandbox/SandboxFs.d.ts.map +1 -1
  78. package/dist/sandbox/types.d.ts +19 -0
  79. package/dist/sandbox/types.d.ts.map +1 -1
  80. package/dist/sed-BHijDEOD.js +95 -0
  81. package/dist/{sort-CSzSGTdB.js → sort-CheGhnUV.js} +19 -14
  82. package/dist/{stat-D0i1gTKB.js → stat-YSBnw2tJ.js} +1 -1
  83. package/dist/tail-9Z1OE7L7.js +52 -0
  84. package/dist/{tar-DkyzTzmT.js → tar-Dc-wpdQT.js} +15 -16
  85. package/dist/{tee-RqoZ3qG-.js → tee-C4QkabXH.js} +1 -1
  86. package/dist/{touch-k2NomRzL.js → touch-BeFpZeqv.js} +1 -1
  87. package/dist/{tree-B_j2_PsZ.js → tree-BiBsUSQR.js} +1 -1
  88. package/dist/uniq-BeGU0UTU.js +54 -0
  89. package/dist/{unzip-FwYCTDEZ.js → unzip-SUXLk4bS.js} +18 -19
  90. package/dist/utils/mime.d.ts +4 -0
  91. package/dist/utils/mime.d.ts.map +1 -0
  92. package/dist/wc-BLupYdzi.js +69 -0
  93. package/dist/{wget-2NAABIHc.js → wget-ALEPUtGk.js} +1 -1
  94. package/dist/{zip--0ncHv0q.js → zip-V6SMbx7b.js} +11 -12
  95. package/package.json +5 -2
  96. package/dist/archive-nRHWNwjH.js +0 -192
  97. package/dist/awk-CchAsBzt.js +0 -118
  98. package/dist/cut-BZez9bS1.js +0 -60
  99. package/dist/diff-tWPvmikU.js +0 -129
  100. package/dist/gunzip-BYlJhPf7.js +0 -48
  101. package/dist/head-DzP_T5Wx.js +0 -48
  102. package/dist/rev-CWRUIXWp.js +0 -34
  103. package/dist/sed-ClWZ06zX.js +0 -90
  104. package/dist/tail-tcIJLQnB.js +0 -47
  105. package/dist/uniq-hzJnHQOm.js +0 -51
  106. package/dist/wc-Jp7nOops.js +0 -60
@@ -1,118 +0,0 @@
1
- import { r as E, V as N } from "./index-DccAPaZF.js";
2
- function S(e) {
3
- const a = [];
4
- let t = e.trim();
5
- for (; t.length > 0 && (t = t.trim(), t.length !== 0); ) {
6
- let n = null, o = "";
7
- if (t.startsWith("BEGIN"))
8
- n = "BEGIN", t = t.slice(5).trim();
9
- else if (t.startsWith("END"))
10
- n = "END", t = t.slice(3).trim();
11
- else if (t.startsWith("/")) {
12
- const i = t.indexOf("/", 1);
13
- if (i > 0) {
14
- try {
15
- n = new RegExp(t.slice(1, i));
16
- } catch {
17
- n = null;
18
- }
19
- t = t.slice(i + 1).trim();
20
- }
21
- }
22
- if (t.startsWith("{")) {
23
- let i = 0, l = 0;
24
- for (; l < t.length; l++)
25
- if (t[l] === "{") i++;
26
- else if (t[l] === "}" && (i--, i === 0))
27
- break;
28
- o = t.slice(1, l).trim(), t = t.slice(l + 1).trim();
29
- } else n === null && (o = t, t = "");
30
- a.push({ pattern: n, action: o });
31
- }
32
- return a;
33
- }
34
- function m(e, a, t, n, o, i, l) {
35
- const f = [], p = e.split(";").map((r) => r.trim()).filter(Boolean);
36
- for (const r of p)
37
- if (r === "print" || r === "print $0")
38
- f.push(t);
39
- else if (r.startsWith("print ")) {
40
- const h = r.slice(6).trim().split(",").map((g) => g.trim()).map((g) => W(g, a, t, n, o, l));
41
- f.push(h.join(" "));
42
- }
43
- return f.join(`
44
- `);
45
- }
46
- function W(e, a, t, n, o, i) {
47
- if (e = e.trim(), e.startsWith('"') && e.endsWith('"'))
48
- return e.slice(1, -1).replace(/\\n/g, `
49
- `).replace(/\\t/g, " ");
50
- if (e.startsWith("$")) {
51
- const l = e.slice(1);
52
- if (l === "NF")
53
- return a[o - 1] || "";
54
- const f = parseInt(l, 10);
55
- return f === 0 ? t : a[f - 1] || "";
56
- }
57
- return e === "NR" ? String(n) : e === "NF" ? String(o) : i.has(e) ? i.get(e) : e;
58
- }
59
- const k = async (e) => {
60
- let a = /\s+/, t = " ", n = "";
61
- const o = [];
62
- for (let r = 0; r < e.args.length; r++) {
63
- const s = e.args[r];
64
- s === "-F" && r + 1 < e.args.length ? (t = e.args[++r], a = new RegExp(t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"))) : s.startsWith("-F") && s.length > 2 ? (t = s.slice(2), a = new RegExp(t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"))) : n ? o.push(s) : n = s;
65
- }
66
- if (!n)
67
- return e.stderr.write(`awk: missing program
68
- `), 1;
69
- let i = "";
70
- if (o.length === 0)
71
- if (e.stdin)
72
- i = await e.stdin.readAll();
73
- else
74
- return e.stderr.write(`awk: missing file operand
75
- `), 1;
76
- else
77
- for (const r of o) {
78
- const s = E(e.cwd, r);
79
- try {
80
- i += e.vfs.readFileString(s);
81
- } catch (c) {
82
- if (c instanceof N)
83
- return e.stderr.write(`awk: ${r}: ${c.message}
84
- `), 1;
85
- throw c;
86
- }
87
- }
88
- const l = S(n), f = i.replace(/\n$/, "").split(`
89
- `), p = /* @__PURE__ */ new Map();
90
- for (const r of l)
91
- if (r.pattern === "BEGIN") {
92
- const s = m(r.action, [], "", 0, 0, t, p);
93
- s && e.stdout.write(s + `
94
- `);
95
- }
96
- for (let r = 0; r < f.length; r++) {
97
- const s = f[r], c = s.split(a).filter((u) => u !== ""), h = r + 1, g = c.length;
98
- for (const u of l) {
99
- if (u.pattern === "BEGIN" || u.pattern === "END") continue;
100
- let d = !0;
101
- if (u.pattern instanceof RegExp && (d = u.pattern.test(s)), d) {
102
- const w = m(u.action, c, s, h, g, t, p);
103
- w && e.stdout.write(w + `
104
- `);
105
- }
106
- }
107
- }
108
- for (const r of l)
109
- if (r.pattern === "END") {
110
- const s = m(r.action, [], "", f.length, 0, t, p);
111
- s && e.stdout.write(s + `
112
- `);
113
- }
114
- return 0;
115
- };
116
- export {
117
- k as default
118
- };
@@ -1,60 +0,0 @@
1
- import { r as d, V as c } from "./index-DccAPaZF.js";
2
- function u(e) {
3
- const r = [];
4
- for (const n of e.split(",")) {
5
- const i = n.split("-");
6
- if (i.length === 2) {
7
- const l = parseInt(i[0], 10), f = parseInt(i[1], 10);
8
- if (!isNaN(l) && !isNaN(f))
9
- for (let a = l; a <= f; a++) r.push(a);
10
- } else {
11
- const l = parseInt(n, 10);
12
- isNaN(l) || r.push(l);
13
- }
14
- }
15
- return r;
16
- }
17
- const h = async (e) => {
18
- let r = " ", n = "";
19
- const i = [];
20
- for (let s = 0; s < e.args.length; s++) {
21
- const t = e.args[s];
22
- t === "-d" && s + 1 < e.args.length ? r = e.args[++s] : t === "-f" && s + 1 < e.args.length ? n = e.args[++s] : t.startsWith("-d") && t.length > 2 ? r = t.slice(2) : t.startsWith("-f") && t.length > 2 ? n = t.slice(2) : i.push(t);
23
- }
24
- if (!n)
25
- return e.stderr.write(`cut: you must specify a list of fields
26
- `), 1;
27
- const l = u(n);
28
- function f(s) {
29
- const t = s.split(r);
30
- return l.map((o) => t[o - 1] || "").join(r);
31
- }
32
- let a = "";
33
- if (i.length === 0)
34
- if (e.stdin)
35
- a = await e.stdin.readAll();
36
- else
37
- return e.stderr.write(`cut: missing file operand
38
- `), 1;
39
- else
40
- for (const s of i) {
41
- const t = d(e.cwd, s);
42
- try {
43
- a += e.vfs.readFileString(t);
44
- } catch (o) {
45
- if (o instanceof c)
46
- return e.stderr.write(`cut: ${s}: ${o.message}
47
- `), 1;
48
- throw o;
49
- }
50
- }
51
- const p = a.replace(/\n$/, "").split(`
52
- `);
53
- for (const s of p)
54
- e.stdout.write(f(s) + `
55
- `);
56
- return 0;
57
- };
58
- export {
59
- h as default
60
- };
@@ -1,129 +0,0 @@
1
- import { p as m } from "./args-CG6b9cZt.js";
2
- import { r as y, V as w } from "./index-DccAPaZF.js";
3
- const C = {
4
- unified: { type: "boolean", short: "u" }
5
- };
6
- function k(o, f) {
7
- const d = o.length, n = f.length, s = Array.from({ length: d + 1 }, () => new Array(n + 1).fill(0));
8
- for (let e = 1; e <= d; e++)
9
- for (let l = 1; l <= n; l++)
10
- o[e - 1] === f[l - 1] ? s[e][l] = s[e - 1][l - 1] + 1 : s[e][l] = Math.max(s[e - 1][l], s[e][l - 1]);
11
- const u = [];
12
- let i = d, r = n;
13
- for (; i > 0 || r > 0; )
14
- i > 0 && r > 0 && o[i - 1] === f[r - 1] ? (u.push({ type: "keep", oldLine: o[i - 1] }), i--, r--) : r > 0 && (i === 0 || s[i][r - 1] >= s[i - 1][r]) ? (u.push({ type: "insert", newLine: f[r - 1] }), r--) : (u.push({ type: "delete", oldLine: o[i - 1] }), i--);
15
- return u.reverse();
16
- }
17
- function S(o) {
18
- const f = [];
19
- let d = 0, n = 0, s = 0;
20
- for (; s < o.length; ) {
21
- if (o[s].type === "keep") {
22
- d++, n++, s++;
23
- continue;
24
- }
25
- const i = d, r = n, e = [], l = [];
26
- for (; s < o.length && o[s].type !== "keep"; )
27
- o[s].type === "delete" ? (e.push(o[s].oldLine), d++) : (l.push(o[s].newLine), n++), s++;
28
- const p = e.length === 1 ? `${i + 1}` : e.length > 0 ? `${i + 1},${i + e.length}` : `${i}`, t = l.length === 1 ? `${r + 1}` : l.length > 0 ? `${r + 1},${r + l.length}` : `${r}`;
29
- if (e.length > 0 && l.length > 0) {
30
- f.push(`${p}c${t}`);
31
- for (const a of e) f.push(`< ${a}`);
32
- f.push("---");
33
- for (const a of l) f.push(`> ${a}`);
34
- } else if (e.length > 0) {
35
- f.push(`${p}d${t}`);
36
- for (const a of e) f.push(`< ${a}`);
37
- } else {
38
- f.push(`${p}a${t}`);
39
- for (const a of l) f.push(`> ${a}`);
40
- }
41
- }
42
- return f.length > 0 ? f.join(`
43
- `) + `
44
- ` : "";
45
- }
46
- function L(o, f, d) {
47
- if (o.every((t) => t.type === "keep")) return "";
48
- const n = [];
49
- let s = 0, u = 0;
50
- for (const t of o)
51
- t.type === "keep" ? (n.push({ type: "keep", line: t.oldLine, oldIdx: s, newIdx: u }), s++, u++) : t.type === "delete" ? (n.push({ type: "delete", line: t.oldLine, oldIdx: s, newIdx: u }), s++) : (n.push({ type: "insert", line: t.newLine, oldIdx: s, newIdx: u }), u++);
52
- const i = 3, r = [];
53
- let e = null, l = -1 / 0;
54
- for (let t = 0; t < n.length; t++) {
55
- const a = n[t];
56
- if (a.type !== "keep") {
57
- if (!e || t - l > i * 2 + 1) {
58
- if (e) {
59
- for (let h = l + 1; h < Math.min(l + 1 + i, n.length); h++)
60
- n[h].type === "keep" && (e.lines.push(` ${n[h].line}`), e.oldCount++, e.newCount++);
61
- r.push(e);
62
- }
63
- const c = Math.max(0, t - i);
64
- let g = 0, $ = 0;
65
- for (let h = 0; h < c; h++)
66
- n[h].type !== "insert" && g++, n[h].type !== "delete" && $++;
67
- e = {
68
- oldStart: g + 1,
69
- newStart: $ + 1,
70
- oldCount: 0,
71
- newCount: 0,
72
- lines: []
73
- };
74
- for (let h = c; h < t; h++)
75
- n[h].type === "keep" && (e.lines.push(` ${n[h].line}`), e.oldCount++, e.newCount++);
76
- } else if (t - l > 1)
77
- for (let c = l + 1; c < t; c++)
78
- n[c].type === "keep" && (e.lines.push(` ${n[c].line}`), e.oldCount++, e.newCount++);
79
- a.type === "delete" ? (e.lines.push(`-${a.line}`), e.oldCount++) : (e.lines.push(`+${a.line}`), e.newCount++), l = t;
80
- }
81
- }
82
- if (e) {
83
- for (let t = l + 1; t < Math.min(l + 1 + i, n.length); t++)
84
- n[t].type === "keep" && (e.lines.push(` ${n[t].line}`), e.oldCount++, e.newCount++);
85
- r.push(e);
86
- }
87
- const p = [];
88
- p.push(`--- ${f}`), p.push(`+++ ${d}`);
89
- for (const t of r)
90
- p.push(`@@ -${t.oldStart},${t.oldCount} +${t.newStart},${t.newCount} @@`), p.push(...t.lines);
91
- return p.join(`
92
- `) + `
93
- `;
94
- }
95
- const v = async (o) => {
96
- const { flags: f, positional: d } = m(o.args, C);
97
- if (d.length < 2)
98
- return o.stderr.write(`diff: missing operand
99
- `), 2;
100
- const n = d[0], s = d[1];
101
- let u, i;
102
- try {
103
- u = o.vfs.readFileString(y(o.cwd, n));
104
- } catch (p) {
105
- if (p instanceof w)
106
- return o.stderr.write(`diff: ${n}: ${p.message}
107
- `), 2;
108
- throw p;
109
- }
110
- try {
111
- i = o.vfs.readFileString(y(o.cwd, s));
112
- } catch (p) {
113
- if (p instanceof w)
114
- return o.stderr.write(`diff: ${s}: ${p.message}
115
- `), 2;
116
- throw p;
117
- }
118
- if (u === i)
119
- return 0;
120
- const r = u.split(`
121
- `), e = i.split(`
122
- `);
123
- r.length > 0 && r[r.length - 1] === "" && r.pop(), e.length > 0 && e[e.length - 1] === "" && e.pop();
124
- const l = k(r, e);
125
- return f.unified ? o.stdout.write(L(l, n, s)) : o.stdout.write(S(l)), 1;
126
- };
127
- export {
128
- v as default
129
- };
@@ -1,48 +0,0 @@
1
- import { r as u, V as d } from "./index-DccAPaZF.js";
2
- import { d as p } from "./archive-nRHWNwjH.js";
3
- const w = async (e) => {
4
- let o = !1;
5
- const t = [];
6
- for (const r of e.args)
7
- switch (r) {
8
- case "-k":
9
- case "--keep":
10
- o = !0;
11
- break;
12
- case "--help":
13
- return e.stdout.write(`Usage: gunzip [-k] file.gz
14
- `), e.stdout.write(` -k, --keep keep original file
15
- `), 0;
16
- default:
17
- if (r.startsWith("-"))
18
- return e.stderr.write(`gunzip: unknown option: ${r}
19
- `), 1;
20
- t.push(r);
21
- }
22
- if (t.length === 0)
23
- return e.stderr.write(`gunzip: missing file operand
24
- `), 1;
25
- let n = 0;
26
- for (const r of t) {
27
- const i = u(e.cwd, r);
28
- try {
29
- if (!i.endsWith(".gz")) {
30
- e.stderr.write(`gunzip: ${r}: unknown suffix -- ignored
31
- `), n = 1;
32
- continue;
33
- }
34
- const s = e.vfs.readFile(i), a = await p(s), f = i.slice(0, -3);
35
- e.vfs.writeFile(f, a), o || e.vfs.unlink(i);
36
- } catch (s) {
37
- if (s instanceof d)
38
- e.stderr.write(`gunzip: ${r}: ${s.message}
39
- `), n = 1;
40
- else
41
- throw s;
42
- }
43
- }
44
- return n;
45
- };
46
- export {
47
- w as default
48
- };
@@ -1,48 +0,0 @@
1
- import { r as d, V as f } from "./index-DccAPaZF.js";
2
- const h = async (e) => {
3
- let r = 10;
4
- const i = [];
5
- for (let t = 0; t < e.args.length; t++) {
6
- const s = e.args[t];
7
- if (s === "-n" && t + 1 < e.args.length) {
8
- if (r = parseInt(e.args[++t], 10), isNaN(r))
9
- return e.stderr.write(`head: invalid number of lines
10
- `), 1;
11
- } else /^-\d+$/.test(s) ? r = parseInt(s.slice(1), 10) : i.push(s);
12
- }
13
- async function a(t) {
14
- const s = t.split(`
15
- `);
16
- let o = s.slice(0, r).join(`
17
- `);
18
- s.length > r && (o += `
19
- `), e.stdout.write(o);
20
- }
21
- if (i.length === 0) {
22
- if (e.stdin)
23
- await a(await e.stdin.readAll());
24
- else
25
- return e.stderr.write(`head: missing file operand
26
- `), 1;
27
- return 0;
28
- }
29
- let l = 0;
30
- for (const t of i) {
31
- const s = d(e.cwd, t);
32
- try {
33
- const n = e.vfs.readFileString(s);
34
- i.length > 1 && e.stdout.write(`==> ${t} <==
35
- `), await a(n);
36
- } catch (n) {
37
- if (n instanceof f)
38
- e.stderr.write(`head: ${t}: ${n.message}
39
- `), l = 1;
40
- else
41
- throw n;
42
- }
43
- }
44
- return l;
45
- };
46
- export {
47
- h as default
48
- };
@@ -1,34 +0,0 @@
1
- import { r as i, V as a } from "./index-DccAPaZF.js";
2
- function s(r) {
3
- return r.split(`
4
- `).map((n) => [...n].reverse().join("")).join(`
5
- `);
6
- }
7
- const f = async (r) => {
8
- if (r.args.length === 0) {
9
- if (r.stdin) {
10
- const t = await r.stdin.readAll();
11
- return r.stdout.write(s(t)), 0;
12
- }
13
- return r.stderr.write(`rev: missing operand
14
- `), 1;
15
- }
16
- let n = 0;
17
- for (const t of r.args) {
18
- const o = i(r.cwd, t);
19
- try {
20
- const e = r.vfs.readFileString(o);
21
- r.stdout.write(s(e));
22
- } catch (e) {
23
- if (e instanceof a)
24
- r.stderr.write(`rev: ${t}: ${e.message}
25
- `), n = 1;
26
- else
27
- throw e;
28
- }
29
- }
30
- return n;
31
- };
32
- export {
33
- f as default
34
- };
@@ -1,90 +0,0 @@
1
- import { r as c, V as g } from "./index-DccAPaZF.js";
2
- function h(e) {
3
- if (e === "d")
4
- return { type: "d" };
5
- if (e === "p")
6
- return { type: "p" };
7
- if (e.startsWith("s")) {
8
- const u = e[1];
9
- if (!u) return null;
10
- const n = [];
11
- let l = "", f = !1;
12
- for (let r = 2; r < e.length; r++)
13
- f ? (l += e[r], f = !1) : e[r] === "\\" ? (f = !0, l += "\\") : e[r] === u ? (n.push(l), l = "") : l += e[r];
14
- if (n.push(l), n.length < 2) return null;
15
- const p = n[0], d = n[1], t = n[2] || "", s = t.includes("g"), i = t.includes("i");
16
- let o;
17
- try {
18
- let r = "";
19
- s && (r += "g"), i && (r += "i"), o = new RegExp(p, r);
20
- } catch {
21
- return null;
22
- }
23
- return { type: "s", pattern: o, replacement: d, global: s };
24
- }
25
- return null;
26
- }
27
- const w = async (e) => {
28
- let u = !1;
29
- const n = [], l = [];
30
- for (let t = 0; t < e.args.length; t++) {
31
- const s = e.args[t];
32
- s === "-i" ? u = !0 : s === "-e" && t + 1 < e.args.length ? n.push(e.args[++t]) : n.length === 0 && !s.startsWith("-") ? n.push(s) : l.push(s);
33
- }
34
- if (n.length === 0)
35
- return e.stderr.write(`sed: missing expression
36
- `), 1;
37
- const f = [];
38
- for (const t of n) {
39
- const s = h(t);
40
- if (!s)
41
- return e.stderr.write(`sed: invalid expression: ${t}
42
- `), 1;
43
- f.push(s);
44
- }
45
- function p(t) {
46
- const s = t.replace(/\n$/, "").split(`
47
- `), i = [];
48
- for (let o of s) {
49
- let r = !1;
50
- for (const a of f)
51
- if (a.type === "s" && a.pattern && a.replacement !== void 0)
52
- o = o.replace(a.pattern, a.replacement);
53
- else if (a.type === "d") {
54
- r = !0;
55
- break;
56
- } else a.type === "p" && i.push(o);
57
- r || i.push(o);
58
- }
59
- return i.join(`
60
- `) + `
61
- `;
62
- }
63
- if (l.length === 0) {
64
- if (e.stdin) {
65
- const t = await e.stdin.readAll();
66
- e.stdout.write(p(t));
67
- } else
68
- return e.stderr.write(`sed: missing file operand
69
- `), 1;
70
- return 0;
71
- }
72
- let d = 0;
73
- for (const t of l) {
74
- const s = c(e.cwd, t);
75
- try {
76
- const i = e.vfs.readFileString(s), o = p(i);
77
- u ? e.vfs.writeFile(s, o) : e.stdout.write(o);
78
- } catch (i) {
79
- if (i instanceof g)
80
- e.stderr.write(`sed: ${t}: ${i.message}
81
- `), d = 1;
82
- else
83
- throw i;
84
- }
85
- }
86
- return d;
87
- };
88
- export {
89
- w as default
90
- };
@@ -1,47 +0,0 @@
1
- import { r as o, V as f } from "./index-DccAPaZF.js";
2
- const g = async (e) => {
3
- let r = 10;
4
- const i = [];
5
- for (let t = 0; t < e.args.length; t++) {
6
- const s = e.args[t];
7
- if (s === "-n" && t + 1 < e.args.length) {
8
- if (r = parseInt(e.args[++t], 10), isNaN(r))
9
- return e.stderr.write(`tail: invalid number of lines
10
- `), 1;
11
- } else /^-\d+$/.test(s) ? r = parseInt(s.slice(1), 10) : i.push(s);
12
- }
13
- async function a(t) {
14
- const n = t.replace(/\n$/, "").split(`
15
- `).slice(-r);
16
- e.stdout.write(n.join(`
17
- `) + `
18
- `);
19
- }
20
- if (i.length === 0) {
21
- if (e.stdin)
22
- await a(await e.stdin.readAll());
23
- else
24
- return e.stderr.write(`tail: missing file operand
25
- `), 1;
26
- return 0;
27
- }
28
- let l = 0;
29
- for (const t of i) {
30
- const s = o(e.cwd, t);
31
- try {
32
- const n = e.vfs.readFileString(s);
33
- i.length > 1 && e.stdout.write(`==> ${t} <==
34
- `), await a(n);
35
- } catch (n) {
36
- if (n instanceof f)
37
- e.stderr.write(`tail: ${t}: ${n.message}
38
- `), l = 1;
39
- else
40
- throw n;
41
- }
42
- }
43
- return l;
44
- };
45
- export {
46
- g as default
47
- };
@@ -1,51 +0,0 @@
1
- import { r as f, V as c } from "./index-DccAPaZF.js";
2
- const g = async (t) => {
3
- let i = !1, l = !1, a = !1;
4
- const r = [];
5
- for (const e of t.args)
6
- if (e.startsWith("-") && e.length > 1)
7
- for (let s = 1; s < e.length; s++)
8
- switch (e[s]) {
9
- case "c":
10
- i = !0;
11
- break;
12
- case "d":
13
- l = !0;
14
- break;
15
- case "u":
16
- a = !0;
17
- break;
18
- }
19
- else
20
- r.push(e);
21
- let o = "";
22
- if (r.length === 0)
23
- if (t.stdin)
24
- o = await t.stdin.readAll();
25
- else
26
- return t.stderr.write(`uniq: missing file operand
27
- `), 1;
28
- else {
29
- const e = f(t.cwd, r[0]);
30
- try {
31
- o = t.vfs.readFileString(e);
32
- } catch (s) {
33
- if (s instanceof c)
34
- return t.stderr.write(`uniq: ${r[0]}: ${s.message}
35
- `), 1;
36
- throw s;
37
- }
38
- }
39
- const u = o.replace(/\n$/, "").split(`
40
- `), n = [];
41
- for (const e of u)
42
- n.length > 0 && n[n.length - 1].line === e ? n[n.length - 1].count++ : n.push({ line: e, count: 1 });
43
- for (const e of n)
44
- l && e.count < 2 || a && e.count > 1 || (i ? t.stdout.write(`${String(e.count).padStart(7)} ${e.line}
45
- `) : t.stdout.write(e.line + `
46
- `));
47
- return 0;
48
- };
49
- export {
50
- g as default
51
- };
@@ -1,60 +0,0 @@
1
- import { r as g, V as p } from "./index-DccAPaZF.js";
2
- const y = async (r) => {
3
- let o = !1, i = !1, l = !1;
4
- const a = [];
5
- for (const t of r.args)
6
- if (t.startsWith("-") && t.length > 1)
7
- for (let e = 1; e < t.length; e++)
8
- switch (t[e]) {
9
- case "l":
10
- o = !0;
11
- break;
12
- case "w":
13
- i = !0;
14
- break;
15
- case "c":
16
- l = !0;
17
- break;
18
- }
19
- else
20
- a.push(t);
21
- !o && !i && !l && (o = i = l = !0);
22
- function d(t) {
23
- const e = t === "" ? 0 : t.split(`
24
- `).length - (t.endsWith(`
25
- `) ? 1 : 0), s = t.trim() === "" ? 0 : t.trim().split(/\s+/).length, n = new TextEncoder().encode(t).length;
26
- return { lines: e, words: s, bytes: n };
27
- }
28
- function f(t, e) {
29
- const s = [];
30
- return o && s.push(String(t.lines).padStart(8)), i && s.push(String(t.words).padStart(8)), l && s.push(String(t.bytes).padStart(8)), e && s.push(" " + e), s.join("") + `
31
- `;
32
- }
33
- if (a.length === 0) {
34
- if (r.stdin) {
35
- const t = await r.stdin.readAll(), e = d(t);
36
- r.stdout.write(f(e));
37
- } else
38
- return r.stderr.write(`wc: missing file operand
39
- `), 1;
40
- return 0;
41
- }
42
- let u = 0, c = 0, h = 0, w = 0;
43
- for (const t of a) {
44
- const e = g(r.cwd, t);
45
- try {
46
- const s = r.vfs.readFileString(e), n = d(s);
47
- c += n.lines, h += n.words, w += n.bytes, r.stdout.write(f(n, t));
48
- } catch (s) {
49
- if (s instanceof p)
50
- r.stderr.write(`wc: ${t}: ${s.message}
51
- `), u = 1;
52
- else
53
- throw s;
54
- }
55
- }
56
- return a.length > 1 && r.stdout.write(f({ lines: c, words: h, bytes: w }, "total")), u;
57
- };
58
- export {
59
- y as default
60
- };