@poe-platform/safe-bash 0.1.145 → 0.1.147
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/README.md +1 -1
- package/dist/safe-bash/browser.d.ts +4 -0
- package/dist/safe-bash/browser.d.ts.map +1 -1
- package/dist/safe-bash/browser.js +4046 -2910
- package/dist/safe-bash/browser.js.map +4 -4
- package/dist/safe-bash/commands/basic.d.ts +3 -1
- package/dist/safe-bash/commands/basic.d.ts.map +1 -1
- package/dist/safe-bash/commands/basic.js +143 -141
- package/dist/safe-bash/commands/basic.js.map +1 -1
- package/dist/safe-bash/commands/execution.d.ts +4 -1
- package/dist/safe-bash/commands/execution.d.ts.map +1 -1
- package/dist/safe-bash/commands/execution.js +134 -32
- package/dist/safe-bash/commands/execution.js.map +1 -1
- package/dist/safe-bash/commands/filesystem.d.ts.map +1 -1
- package/dist/safe-bash/commands/filesystem.js +161 -39
- package/dist/safe-bash/commands/filesystem.js.map +1 -1
- package/dist/safe-bash/commands/find.d.ts.map +1 -1
- package/dist/safe-bash/commands/find.js +83 -3
- package/dist/safe-bash/commands/find.js.map +1 -1
- package/dist/safe-bash/commands/index.d.ts +4 -0
- package/dist/safe-bash/commands/index.d.ts.map +1 -1
- package/dist/safe-bash/commands/index.js +1 -1
- package/dist/safe-bash/commands/index.js.map +1 -1
- package/dist/safe-bash/commands/regex-execution/ere/matcher.d.ts.map +1 -1
- package/dist/safe-bash/commands/regex-execution/ere/matcher.js +35 -15
- package/dist/safe-bash/commands/regex-execution/ere/matcher.js.map +1 -1
- package/dist/safe-bash/commands/search/file-types.d.ts +2 -0
- package/dist/safe-bash/commands/search/file-types.d.ts.map +1 -0
- package/dist/safe-bash/commands/search/file-types.js +229 -0
- package/dist/safe-bash/commands/search/file-types.js.map +1 -0
- package/dist/safe-bash/commands/search/options.d.ts +4 -0
- package/dist/safe-bash/commands/search/options.d.ts.map +1 -1
- package/dist/safe-bash/commands/search/options.js +14 -1
- package/dist/safe-bash/commands/search/options.js.map +1 -1
- package/dist/safe-bash/commands/search/walk.d.ts +2 -0
- package/dist/safe-bash/commands/search/walk.d.ts.map +1 -1
- package/dist/safe-bash/commands/search/walk.js +32 -0
- package/dist/safe-bash/commands/search/walk.js.map +1 -1
- package/dist/safe-bash/commands/streams.d.ts +1 -1
- package/dist/safe-bash/commands/streams.d.ts.map +1 -1
- package/dist/safe-bash/commands/streams.js +7 -1
- package/dist/safe-bash/commands/streams.js.map +1 -1
- package/dist/safe-bash/commands/structured/interpreter.d.ts +9 -1
- package/dist/safe-bash/commands/structured/interpreter.d.ts.map +1 -1
- package/dist/safe-bash/commands/structured/interpreter.js +78 -2
- package/dist/safe-bash/commands/structured/interpreter.js.map +1 -1
- package/dist/safe-bash/commands/structured/parser.d.ts +13 -0
- package/dist/safe-bash/commands/structured/parser.d.ts.map +1 -1
- package/dist/safe-bash/commands/structured/parser.js +49 -2
- package/dist/safe-bash/commands/structured/parser.js.map +1 -1
- package/dist/safe-bash/commands/table-text/join.d.ts.map +1 -1
- package/dist/safe-bash/commands/table-text/join.js +7 -2
- package/dist/safe-bash/commands/table-text/join.js.map +1 -1
- package/dist/safe-bash/commands/text-programs/sed.d.ts.map +1 -1
- package/dist/safe-bash/commands/text-programs/sed.js +98 -29
- package/dist/safe-bash/commands/text-programs/sed.js.map +1 -1
- package/dist/safe-bash/commands/text.d.ts.map +1 -1
- package/dist/safe-bash/commands/text.js +26 -16
- package/dist/safe-bash/commands/text.js.map +1 -1
- package/dist/safe-bash/plugins/index.d.ts +3 -0
- package/dist/safe-bash/plugins/index.d.ts.map +1 -1
- package/dist/safe-bash/plugins/index.js +1 -1
- package/dist/safe-bash/plugins/index.js.map +1 -1
- package/dist/safe-bash/shell/brace-expansion.d.ts +6 -0
- package/dist/safe-bash/shell/brace-expansion.d.ts.map +1 -0
- package/dist/safe-bash/shell/brace-expansion.js +335 -0
- package/dist/safe-bash/shell/brace-expansion.js.map +1 -0
- package/dist/safe-bash/shell/parser.d.ts +10 -1
- package/dist/safe-bash/shell/parser.d.ts.map +1 -1
- package/dist/safe-bash/shell/parser.js +92 -18
- package/dist/safe-bash/shell/parser.js.map +1 -1
- package/dist/safe-bash/shell/runtime.d.ts +4 -2
- package/dist/safe-bash/shell/runtime.d.ts.map +1 -1
- package/dist/safe-bash/shell/runtime.js +239 -38
- package/dist/safe-bash/shell/runtime.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import { shellValueByteLength } from "../contracts/value.js";
|
|
2
|
+
import { yieldTurn } from "../contracts/yield.js";
|
|
3
|
+
import { expansionSpellings, parseBraceWord } from "./parser.js";
|
|
4
|
+
import { ShellSyntaxError } from "./types.js";
|
|
5
|
+
export class BraceExpansionFailure extends Error {
|
|
6
|
+
}
|
|
7
|
+
async function integer(text, checkpoint) {
|
|
8
|
+
let offset = text.startsWith("-") || text.startsWith("+") ? 1 : 0;
|
|
9
|
+
if (offset === text.length)
|
|
10
|
+
return undefined;
|
|
11
|
+
while (text[offset] === "0") {
|
|
12
|
+
if (offset % 1024 === 0)
|
|
13
|
+
await checkpoint();
|
|
14
|
+
offset++;
|
|
15
|
+
}
|
|
16
|
+
if (text.length - offset > 19)
|
|
17
|
+
return undefined;
|
|
18
|
+
for (let index = offset; index < text.length; index++)
|
|
19
|
+
if (text[index] < "0" || text[index] > "9")
|
|
20
|
+
return undefined;
|
|
21
|
+
const value = BigInt(text.slice(offset) || "0") * (text.startsWith("-") ? -1n : 1n);
|
|
22
|
+
return value < -9223372036854775808n || value > 9223372036854775807n ? undefined : value;
|
|
23
|
+
}
|
|
24
|
+
export async function* expandBraces(word, budget, signal) {
|
|
25
|
+
const allocation = budget.values.scope();
|
|
26
|
+
let work = 0;
|
|
27
|
+
let changed = false;
|
|
28
|
+
const checkpoint = async () => {
|
|
29
|
+
budget.cpuCheckpoint();
|
|
30
|
+
signal.throwIfAborted();
|
|
31
|
+
if (++work % 128 === 0)
|
|
32
|
+
await yieldTurn(signal);
|
|
33
|
+
};
|
|
34
|
+
const admit = (bytes = 64) => {
|
|
35
|
+
budget.parsing.admit();
|
|
36
|
+
allocation.reserve(bytes, 0);
|
|
37
|
+
};
|
|
38
|
+
const sum = (left, right, limit) => {
|
|
39
|
+
if (right > budget.limits[limit] - left)
|
|
40
|
+
budget.fail(limit);
|
|
41
|
+
return left + right;
|
|
42
|
+
};
|
|
43
|
+
const multiply = (left, right, limit) => {
|
|
44
|
+
if (left !== 0 && right > Math.floor(budget.limits[limit] / left))
|
|
45
|
+
budget.fail(limit);
|
|
46
|
+
return left * right;
|
|
47
|
+
};
|
|
48
|
+
const partNode = (part) => {
|
|
49
|
+
admit();
|
|
50
|
+
return { kind: "part", part, count: 1, bytes: part.kind === "text" ? shellValueByteLength(part.byteValue ?? part.value) : 0 };
|
|
51
|
+
};
|
|
52
|
+
const textNode = (value) => {
|
|
53
|
+
admit(value.length * 2);
|
|
54
|
+
return partNode({ kind: "text", value, quoted: false });
|
|
55
|
+
};
|
|
56
|
+
const product = async (children) => {
|
|
57
|
+
admit();
|
|
58
|
+
let count = 1;
|
|
59
|
+
let bytes = 0;
|
|
60
|
+
for (const child of children) {
|
|
61
|
+
await checkpoint();
|
|
62
|
+
bytes = sum(multiply(bytes, child.count, "maxExpansionBytes"), multiply(child.bytes, count, "maxExpansionBytes"), "maxExpansionBytes");
|
|
63
|
+
count = multiply(count, child.count, "maxExpansionFields");
|
|
64
|
+
}
|
|
65
|
+
return { kind: "product", children, count, bytes };
|
|
66
|
+
};
|
|
67
|
+
const sequence = async (children) => {
|
|
68
|
+
if (children.length !== 1 || children[0].kind !== "part")
|
|
69
|
+
return undefined;
|
|
70
|
+
const part = children[0].part;
|
|
71
|
+
if (part.kind !== "text" || part.quoted || part.byteValue)
|
|
72
|
+
return undefined;
|
|
73
|
+
admit(32);
|
|
74
|
+
const pieces = [];
|
|
75
|
+
let startOffset = 0;
|
|
76
|
+
for (let offset = 0; offset < part.value.length; offset++) {
|
|
77
|
+
if (offset % 1024 === 0)
|
|
78
|
+
await checkpoint();
|
|
79
|
+
if (part.value[offset] !== "." || part.value[offset + 1] !== ".")
|
|
80
|
+
continue;
|
|
81
|
+
if (pieces.length === 2)
|
|
82
|
+
return undefined;
|
|
83
|
+
admit(16 + (offset - startOffset) * 2);
|
|
84
|
+
pieces.push(part.value.slice(startOffset, offset));
|
|
85
|
+
startOffset = offset + 2;
|
|
86
|
+
offset++;
|
|
87
|
+
}
|
|
88
|
+
if (!pieces.length)
|
|
89
|
+
return undefined;
|
|
90
|
+
admit(16 + (part.value.length - startOffset) * 2);
|
|
91
|
+
pieces.push(part.value.slice(startOffset));
|
|
92
|
+
const first = pieces[0];
|
|
93
|
+
const last = pieces[1];
|
|
94
|
+
admit(256);
|
|
95
|
+
let start = await integer(first, checkpoint);
|
|
96
|
+
let end = await integer(last, checkpoint);
|
|
97
|
+
const numeric = start !== undefined && end !== undefined;
|
|
98
|
+
if (!numeric) {
|
|
99
|
+
const alphabetic = (value) => value.length === 1 && (value >= "a" && value <= "z" || value >= "A" && value <= "Z");
|
|
100
|
+
if (!alphabetic(first) || !alphabetic(last))
|
|
101
|
+
return undefined;
|
|
102
|
+
start = BigInt(first.charCodeAt(0));
|
|
103
|
+
end = BigInt(last.charCodeAt(0));
|
|
104
|
+
}
|
|
105
|
+
let step = pieces.length === 3 ? await integer(pieces[2], checkpoint) : 1n;
|
|
106
|
+
if (step === undefined)
|
|
107
|
+
return undefined;
|
|
108
|
+
if (step < 0n)
|
|
109
|
+
step = -step;
|
|
110
|
+
if (step === 0n)
|
|
111
|
+
step = 1n;
|
|
112
|
+
const distance = end - start;
|
|
113
|
+
const cardinality = (distance < 0n ? -distance : distance) / step + 1n;
|
|
114
|
+
if (cardinality > BigInt(budget.limits.maxExpansionFields))
|
|
115
|
+
budget.fail("maxExpansionFields");
|
|
116
|
+
const padded = (value) => value.length > 1 && value.startsWith("0") || value.length > 2 && value.startsWith("-0");
|
|
117
|
+
const width = numeric && (padded(first) || padded(last)) ? Math.max(first.length, last.length) : 0;
|
|
118
|
+
const count = Number(cardinality);
|
|
119
|
+
const termBytes = numeric ? Math.max(width, start.toString().length, end.toString().length) : 1;
|
|
120
|
+
const bytes = multiply(count, termBytes, "maxExpansionBytes");
|
|
121
|
+
admit();
|
|
122
|
+
return { kind: "range", start: start, step: distance < 0n ? -step : step, width, numeric, count, bytes };
|
|
123
|
+
};
|
|
124
|
+
try {
|
|
125
|
+
admit();
|
|
126
|
+
const frames = [{ branches: [[]] }];
|
|
127
|
+
const append = (node) => { frames.at(-1).branches.at(-1).push(node); };
|
|
128
|
+
for (const part of word.parts) {
|
|
129
|
+
await checkpoint();
|
|
130
|
+
if (part.kind !== "text" || part.quoted || part.byteValue) {
|
|
131
|
+
append(partNode(part));
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
let start = 0;
|
|
135
|
+
for (let offset = 0; offset < part.value.length; offset++) {
|
|
136
|
+
if (offset % 1024 === 0) {
|
|
137
|
+
budget.parsing.admit();
|
|
138
|
+
await checkpoint();
|
|
139
|
+
}
|
|
140
|
+
const character = part.value[offset];
|
|
141
|
+
if (character !== "{" && character !== "}" && character !== ",")
|
|
142
|
+
continue;
|
|
143
|
+
if (start < offset) {
|
|
144
|
+
admit((offset - start) * 2);
|
|
145
|
+
append(textNode(part.value.slice(start, offset)));
|
|
146
|
+
}
|
|
147
|
+
start = offset + 1;
|
|
148
|
+
if (character === "{") {
|
|
149
|
+
admit();
|
|
150
|
+
frames.push({ branches: [[]] });
|
|
151
|
+
}
|
|
152
|
+
else if (character === "," && frames.length > 1) {
|
|
153
|
+
admit();
|
|
154
|
+
frames.at(-1).branches.push([]);
|
|
155
|
+
}
|
|
156
|
+
else if (character === "}" && frames.length > 1) {
|
|
157
|
+
const frame = frames.pop();
|
|
158
|
+
if (frame.branches.length > 1) {
|
|
159
|
+
admit(frame.branches.length * 8);
|
|
160
|
+
const children = [];
|
|
161
|
+
for (const branch of frame.branches)
|
|
162
|
+
children.push(await product(branch));
|
|
163
|
+
let count = 0;
|
|
164
|
+
let bytes = 0;
|
|
165
|
+
for (const child of children) {
|
|
166
|
+
await checkpoint();
|
|
167
|
+
count = sum(count, child.count, "maxExpansionFields");
|
|
168
|
+
bytes = sum(bytes, child.bytes, "maxExpansionBytes");
|
|
169
|
+
}
|
|
170
|
+
append({ kind: "choice", children, count, bytes });
|
|
171
|
+
changed = true;
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
const children = frame.branches[0];
|
|
175
|
+
const range = await sequence(children);
|
|
176
|
+
if (range) {
|
|
177
|
+
append(range);
|
|
178
|
+
changed = true;
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
append(textNode("{"));
|
|
182
|
+
append(await product(children));
|
|
183
|
+
append(textNode("}"));
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
else
|
|
188
|
+
append(textNode(character));
|
|
189
|
+
}
|
|
190
|
+
if (start < part.value.length) {
|
|
191
|
+
if (start === 0)
|
|
192
|
+
append(partNode(part));
|
|
193
|
+
else {
|
|
194
|
+
admit((part.value.length - start) * 2);
|
|
195
|
+
append(textNode(part.value.slice(start)));
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
while (frames.length > 1) {
|
|
200
|
+
await checkpoint();
|
|
201
|
+
const frame = frames.pop();
|
|
202
|
+
append(textNode("{"));
|
|
203
|
+
for (let index = 0; index < frame.branches.length; index++) {
|
|
204
|
+
if (index)
|
|
205
|
+
append(textNode(","));
|
|
206
|
+
append(await product(frame.branches[index]));
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (!changed) {
|
|
210
|
+
yield word;
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const root = await product(frames[0].branches[0]);
|
|
214
|
+
for (let rank = 0; rank < root.count; rank++) {
|
|
215
|
+
await checkpoint();
|
|
216
|
+
const materialized = budget.values.scope();
|
|
217
|
+
try {
|
|
218
|
+
materialized.reserve(64, 0);
|
|
219
|
+
const parts = [];
|
|
220
|
+
const generatedSyntax = new WeakSet();
|
|
221
|
+
const pending = [{ node: root, rank }];
|
|
222
|
+
while (pending.length) {
|
|
223
|
+
await checkpoint();
|
|
224
|
+
const current = pending.pop();
|
|
225
|
+
const node = current.node;
|
|
226
|
+
if (node.kind === "product") {
|
|
227
|
+
materialized.reserve(node.children.length * 32, 0);
|
|
228
|
+
let divisor = 1;
|
|
229
|
+
for (let index = node.children.length - 1; index >= 0; index--) {
|
|
230
|
+
await checkpoint();
|
|
231
|
+
const child = node.children[index];
|
|
232
|
+
pending.push({ node: child, rank: Math.floor(current.rank / divisor) % child.count });
|
|
233
|
+
divisor *= child.count;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
else if (node.kind === "choice") {
|
|
237
|
+
let choice = current.rank;
|
|
238
|
+
for (const child of node.children) {
|
|
239
|
+
await checkpoint();
|
|
240
|
+
if (choice < child.count) {
|
|
241
|
+
materialized.reserve(32, 0);
|
|
242
|
+
pending.push({ node: child, rank: choice });
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
choice -= child.count;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
materialized.reserve(64, 0);
|
|
250
|
+
let part;
|
|
251
|
+
if (node.kind === "part")
|
|
252
|
+
part = node.part;
|
|
253
|
+
else {
|
|
254
|
+
const value = node.start + BigInt(current.rank) * node.step;
|
|
255
|
+
materialized.reserve(Math.max(node.width, 32) * 2, 0);
|
|
256
|
+
const digits = node.numeric ? (value < 0n ? -value : value).toString() : String.fromCharCode(Number(value));
|
|
257
|
+
const text = node.numeric ? (value < 0n ? "-" : "") + digits.padStart(node.width - Number(value < 0n), "0") : digits;
|
|
258
|
+
part = { kind: "text", value: text, quoted: false };
|
|
259
|
+
if (!node.numeric && (text === "\\" || text === "`")) {
|
|
260
|
+
materialized.reserve(32, 0);
|
|
261
|
+
generatedSyntax.add(part);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
const previous = parts.at(-1);
|
|
265
|
+
if (part.kind === "text" && !part.quoted && !part.byteValue && !generatedSyntax.has(part) && previous?.kind === "text" && !previous.quoted && !previous.byteValue && !generatedSyntax.has(previous)) {
|
|
266
|
+
materialized.reserve((previous.value.length + part.value.length) * 2, 0);
|
|
267
|
+
parts[parts.length - 1] = { kind: "text", value: previous.value + part.value, quoted: false };
|
|
268
|
+
}
|
|
269
|
+
else
|
|
270
|
+
parts.push(part);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
for (let index = 0; index < parts.length; index++) {
|
|
274
|
+
await checkpoint();
|
|
275
|
+
const part = parts[index];
|
|
276
|
+
if (!generatedSyntax.has(part) || part.kind !== "text")
|
|
277
|
+
continue;
|
|
278
|
+
materialized.reserve(128, 0);
|
|
279
|
+
const fragments = [];
|
|
280
|
+
const opaque = new Map();
|
|
281
|
+
let length = 0;
|
|
282
|
+
for (let position = index; position < parts.length; position++) {
|
|
283
|
+
await checkpoint();
|
|
284
|
+
const current = parts[position];
|
|
285
|
+
const spelling = expansionSpellings.get(current);
|
|
286
|
+
materialized.reserve(32, 0);
|
|
287
|
+
let fragment;
|
|
288
|
+
if (current.kind === "text" && current.byteValue) {
|
|
289
|
+
materialized.reserve(64, 0);
|
|
290
|
+
opaque.set(length + 1, current.byteValue);
|
|
291
|
+
fragment = "'\0'";
|
|
292
|
+
}
|
|
293
|
+
else if (current.kind === "text" && spelling?.ansi) {
|
|
294
|
+
materialized.reserve(current.value.length * 8 + 4, 0);
|
|
295
|
+
fragment = "'" + current.value.replaceAll("'", "'\\''") + "'";
|
|
296
|
+
}
|
|
297
|
+
else if (spelling && (current.kind !== "text" || current.quoted)) {
|
|
298
|
+
materialized.reserve((spelling.end - spelling.start) * 2, 0);
|
|
299
|
+
fragment = spelling.source.slice(spelling.start, spelling.end);
|
|
300
|
+
}
|
|
301
|
+
else if (current.kind === "text")
|
|
302
|
+
fragment = current.value;
|
|
303
|
+
else
|
|
304
|
+
throw new BraceExpansionFailure("Missing lexical provenance in brace expansion");
|
|
305
|
+
length = sum(length, fragment.length, "maxExpansionBytes");
|
|
306
|
+
fragments.push(fragment);
|
|
307
|
+
}
|
|
308
|
+
materialized.reserve(length * 2, 0);
|
|
309
|
+
let replayed;
|
|
310
|
+
try {
|
|
311
|
+
replayed = parseBraceWord(fragments.join(""), opaque, budget.parsing);
|
|
312
|
+
}
|
|
313
|
+
catch (error) {
|
|
314
|
+
if (!(error instanceof ShellSyntaxError))
|
|
315
|
+
throw error;
|
|
316
|
+
throw new BraceExpansionFailure(error.reason);
|
|
317
|
+
}
|
|
318
|
+
materialized.reserve(replayed.parts.length * 32, 0);
|
|
319
|
+
parts.length = index;
|
|
320
|
+
for (const replayedPart of replayed.parts)
|
|
321
|
+
parts.push(replayedPart);
|
|
322
|
+
break;
|
|
323
|
+
}
|
|
324
|
+
yield { parts, offset: word.offset };
|
|
325
|
+
}
|
|
326
|
+
finally {
|
|
327
|
+
materialized.close();
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
finally {
|
|
332
|
+
allocation.close();
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
//# sourceMappingURL=brace-expansion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brace-expansion.js","sourceRoot":"","sources":["../../src/shell/brace-expansion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAc9C,MAAM,OAAO,qBAAsB,SAAQ,KAAK;CAAG;AAEnD,KAAK,UAAU,OAAO,CAAC,IAAY,EAAE,UAA+B;IAClE,IAAI,MAAM,GAAG,IAAI,C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AC;QACrC,CAAC;IACH,CAAC;YAAS,CAAC;QAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IAAC,CAAC;AACnC,CAAC"}
|
|
@@ -2,8 +2,9 @@ import type { ShellParseOptions } from "./types.js";
|
|
|
2
2
|
import { ParseBudget } from "./parse-budget.js";
|
|
3
3
|
import { SourceLineIndex } from "./source-line-index.js";
|
|
4
4
|
import type { ArithmeticProgram } from "./arithmetic.js";
|
|
5
|
+
import type { ArrayEntry } from "./arrays/syntax.js";
|
|
5
6
|
import type { ConditionalExpression } from "./conditional.js";
|
|
6
|
-
import type { ByteShellValue } from "../contracts/value.js";
|
|
7
|
+
import type { ByteShellValue, ShellValue } from "../contracts/value.js";
|
|
7
8
|
export type WordPart = {
|
|
8
9
|
kind: "text";
|
|
9
10
|
value: string;
|
|
@@ -47,6 +48,13 @@ export interface Word {
|
|
|
47
48
|
readonly spelling?: string;
|
|
48
49
|
readonly printedNewlines?: number;
|
|
49
50
|
}
|
|
51
|
+
export declare const compoundEntryWords: WeakMap<ArrayEntry, Word>;
|
|
52
|
+
export declare const expansionSpellings: WeakMap<WordPart, {
|
|
53
|
+
source: string;
|
|
54
|
+
start: number;
|
|
55
|
+
end: number;
|
|
56
|
+
ansi?: boolean;
|
|
57
|
+
}>;
|
|
50
58
|
export interface HereDocument {
|
|
51
59
|
readonly delimiter: string;
|
|
52
60
|
readonly quoted: boolean;
|
|
@@ -140,6 +148,7 @@ export interface Script {
|
|
|
140
148
|
readonly printedNewlines?: number;
|
|
141
149
|
}
|
|
142
150
|
export declare function parseShell(source: string, depth?: number, options?: ShellParseOptions): Script;
|
|
151
|
+
export declare function parseBraceWord(source: string, opaque: ReadonlyMap<number, ShellValue>, budget: ParseBudget): Word;
|
|
143
152
|
export declare function hereDocumentWords(document: HereDocument, line: number, byteLocale: boolean, warnings: string[], budget?: ParseBudget): Generator<Word>;
|
|
144
153
|
export declare function parseShellUnit(source: string, position?: number, byteLocale?: boolean, budget?: ParseBudget, lineIndex?: SourceLineIndex): {
|
|
145
154
|
script: Script;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/shell/parser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/shell/parser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,KAAK,EAAE,UAAU,EAAiB,MAAM,oBAAoB,CAAC;AAEpE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAE9D,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExE,MAAM,MAAM,QAAQ,GAChB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,cAAc,CAAA;CAAE,GAC5E;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,UAAU,EAAE,iBAAiB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GACpG;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;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E,CAAC;IACxB,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACrD,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;CACnC;AA80BD,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,SAAI,EAAE,OAAO,GAAE,iBAAsB,GAAG,MAAM,CAM7F;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAKjH;AAED,wBAAiB,iBAAiB,CAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,MAAM,cAAoB,GAAG,SAAS,CAAC,IAAI,CAAC,CAG7J;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,SAAI,EAAE,UAAU,UAAQ,EAAE,MAAM,cAAoB,EAAE,SAAS,kBAAsC,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAW9L;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,UAAQ,EAAE,MAAM,cAAoB,EAAE,SAAS,kBAAsC,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAcjM"}
|
|
@@ -5,6 +5,8 @@ import { arithmeticEnd, prepareArithmetic } from "./arithmetic.js";
|
|
|
5
5
|
import { arraySelector, compoundEntry, compoundHead, elementAssignment, getArrayAssignment, scalarAssignmentName, setArrayAssignment, setArraySelector, setQuoteMarker } from "./arrays/syntax.js";
|
|
6
6
|
import { conditionalBinary, conditionalUnary } from "./conditional.js";
|
|
7
7
|
import { shellValueFromBytes, shellValueText } from "../contracts/value.js";
|
|
8
|
+
export const compoundEntryWords = new WeakMap();
|
|
9
|
+
export const expansionSpellings = new WeakMap();
|
|
8
10
|
export class HereDocumentSyntaxError extends Error {
|
|
9
11
|
diagnostic;
|
|
10
12
|
constructor(diagnostic) {
|
|
@@ -53,6 +55,7 @@ class Lexer {
|
|
|
53
55
|
delimiterOperator;
|
|
54
56
|
conditional = false;
|
|
55
57
|
conditionalPattern;
|
|
58
|
+
braceReplay;
|
|
56
59
|
documents = [];
|
|
57
60
|
constructor(budget, source, depth, warnings = [], lineOffset = 0, byteLocale = false, documentLine, partial = false, lineIndex = new SourceLineIndex(source, budget), sourceOffset = 0) {
|
|
58
61
|
this.budget = budget;
|
|
@@ -287,15 +290,18 @@ class Lexer {
|
|
|
287
290
|
let regexClass = "";
|
|
288
291
|
const conditionalPattern = terminator === undefined ? this.conditionalPattern : undefined;
|
|
289
292
|
let plain = true;
|
|
290
|
-
const text = (value, quoted, synthetic = false) => {
|
|
293
|
+
const text = (value, quoted, synthetic = false, start = this.position, end = start + shellValueText(value).length, ansi = false) => {
|
|
291
294
|
const projection = shellValueText(value);
|
|
292
295
|
if (conditionalPattern === "regex" && regexBracket && quoted && projection.length) {
|
|
293
296
|
regexBracketFirst = false;
|
|
294
297
|
regexBracketNegation = false;
|
|
295
298
|
}
|
|
296
299
|
const previous = parts.at(-1);
|
|
297
|
-
if (previous?.kind === "text" && previous.quoted === quoted && !previous.byteValue && typeof value === "string") {
|
|
300
|
+
if (previous?.kind === "text" && previous.quoted === quoted && !previous.byteValue && typeof value === "string" && !ansi && !expansionSpellings.get(previous)?.ansi) {
|
|
298
301
|
previous.value += value;
|
|
302
|
+
const spelling = expansionSpellings.get(previous);
|
|
303
|
+
if (spelling)
|
|
304
|
+
spelling.end = end;
|
|
299
305
|
if (!synthetic)
|
|
300
306
|
setQuoteMarker(previous, false);
|
|
301
307
|
}
|
|
@@ -303,11 +309,21 @@ class Lexer {
|
|
|
303
309
|
this.budget.admit();
|
|
304
310
|
const part = { kind: "text", value: projection, quoted, ...(typeof value === "string" ? {} : { byteValue: value }) };
|
|
305
311
|
setQuoteMarker(part, synthetic);
|
|
312
|
+
if ((quoted || ansi) && this.documentLine === undefined) {
|
|
313
|
+
this.budget.admit();
|
|
314
|
+
expansionSpellings.set(part, { source: this.source, start, end, ...(ansi ? { ansi } : {}) });
|
|
315
|
+
}
|
|
306
316
|
parts.push(part);
|
|
307
317
|
}
|
|
308
318
|
};
|
|
309
319
|
while (this.position < this.source.length) {
|
|
310
320
|
const current = this.source[this.position];
|
|
321
|
+
const opaque = this.braceReplay?.get(this.position);
|
|
322
|
+
if (opaque !== undefined) {
|
|
323
|
+
text(opaque, false);
|
|
324
|
+
this.position++;
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
311
327
|
if (conditionalPattern) {
|
|
312
328
|
if (/[ \t\n;]/u.test(current))
|
|
313
329
|
break;
|
|
@@ -344,35 +360,59 @@ class Lexer {
|
|
|
344
360
|
else if (/[()<>]/u.test(current) || patternParentheses === 0 && (this.source.startsWith("&&", this.position) || this.source.startsWith("||", this.position)))
|
|
345
361
|
break;
|
|
346
362
|
}
|
|
347
|
-
else if (terminator ? terminator.includes(current) && (!arithmetic || current !== ":" || parentheses === 0 && conditionals === 0) : /[ \t\n;|&()<>]/u.test(current))
|
|
363
|
+
else if (terminator ? terminator.includes(current) && (!arithmetic || current !== ":" || parentheses === 0 && conditionals === 0) : !this.braceReplay && /[ \t\n;|&()<>]/u.test(current))
|
|
348
364
|
break;
|
|
349
365
|
if (current === "$" && this.source[this.position + 1] === "'" && !enclosingQuoted && !literal) {
|
|
350
366
|
plain = false;
|
|
351
367
|
this.unprintedWords++;
|
|
352
|
-
|
|
368
|
+
const start = this.position;
|
|
369
|
+
const value = this.ansiWord();
|
|
370
|
+
text(value, true, false, start, this.position, true);
|
|
353
371
|
}
|
|
354
372
|
else if (current === "'" && !enclosingQuoted) {
|
|
355
373
|
plain = false;
|
|
356
|
-
|
|
357
|
-
if (end === -1)
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
374
|
+
let end = this.source.indexOf("'", this.position + 1);
|
|
375
|
+
if (end === -1) {
|
|
376
|
+
if (!this.braceReplay)
|
|
377
|
+
this.error("Unterminated single quote", { quote: "'", line: this.lineAt(this.position) });
|
|
378
|
+
end = this.source.length;
|
|
379
|
+
}
|
|
380
|
+
if (this.braceReplay?.size) {
|
|
381
|
+
let start = this.position + 1;
|
|
382
|
+
for (let position = start; position < end; position++) {
|
|
383
|
+
const opaque = this.braceReplay.get(position);
|
|
384
|
+
if (opaque === undefined)
|
|
385
|
+
continue;
|
|
386
|
+
if (position > start)
|
|
387
|
+
text(this.source.slice(start, position), true, false, start, position);
|
|
388
|
+
text(opaque, true, false, position, position + 1);
|
|
389
|
+
start = position + 1;
|
|
390
|
+
}
|
|
391
|
+
text(this.source.slice(start, end), true, false, start, end);
|
|
392
|
+
}
|
|
393
|
+
else
|
|
394
|
+
text(this.source.slice(this.position + 1, end), true, false, this.position, Math.min(end + 1, this.source.length));
|
|
395
|
+
this.position = Math.min(end + 1, this.source.length);
|
|
361
396
|
}
|
|
362
397
|
else if (current === '"') {
|
|
363
398
|
plain = false;
|
|
364
399
|
const quoteLine = this.lineAt(this.position);
|
|
365
400
|
this.position++;
|
|
366
|
-
text("", true, true);
|
|
401
|
+
text("", true, true, this.position - 1, this.position);
|
|
367
402
|
const quoteParts = parts.length;
|
|
368
403
|
while (this.position < this.source.length && this.source[this.position] !== '"') {
|
|
369
404
|
const inner = this.source[this.position];
|
|
370
|
-
|
|
405
|
+
const opaque = this.braceReplay?.get(this.position);
|
|
406
|
+
if (opaque !== undefined) {
|
|
407
|
+
text(opaque, true);
|
|
408
|
+
this.position++;
|
|
409
|
+
}
|
|
410
|
+
else if (!literal && (inner === "$" || inner === "`"))
|
|
371
411
|
this.expansion(parts, true);
|
|
372
412
|
else if (inner === "\\" && /[$`"\\\n]/u.test(this.source[this.position + 1] ?? "")) {
|
|
373
413
|
const escaped = this.source[this.position + 1];
|
|
374
414
|
if (escaped !== "\n")
|
|
375
|
-
text(escaped, true);
|
|
415
|
+
text(escaped, true, false, this.position, this.position + 2);
|
|
376
416
|
else
|
|
377
417
|
this.printedNewlineReduction++;
|
|
378
418
|
this.position += 2;
|
|
@@ -382,20 +422,28 @@ class Lexer {
|
|
|
382
422
|
this.position++;
|
|
383
423
|
}
|
|
384
424
|
}
|
|
385
|
-
if (this.source[this.position] !== '"')
|
|
425
|
+
if (this.source[this.position] !== '"' && !this.braceReplay)
|
|
386
426
|
this.error("Unterminated double quote", { quote: '"', line: quoteLine });
|
|
387
427
|
if (parts.length === quoteParts)
|
|
388
428
|
setQuoteMarker(parts.at(-1), false);
|
|
389
|
-
|
|
429
|
+
const spelling = expansionSpellings.get(parts.at(-1));
|
|
430
|
+
if (spelling)
|
|
431
|
+
spelling.end = Math.min(this.position + 1, this.source.length);
|
|
432
|
+
if (this.position < this.source.length)
|
|
433
|
+
this.position++;
|
|
390
434
|
}
|
|
391
435
|
else if (current === "\\") {
|
|
392
436
|
if (this.source[this.position + 1] !== "\n")
|
|
393
437
|
plain = false;
|
|
394
438
|
this.position++;
|
|
395
|
-
if (this.position === this.source.length)
|
|
396
|
-
this.
|
|
439
|
+
if (this.position === this.source.length) {
|
|
440
|
+
if (!this.braceReplay)
|
|
441
|
+
this.error("Trailing escape");
|
|
442
|
+
text("", true);
|
|
443
|
+
break;
|
|
444
|
+
}
|
|
397
445
|
if (this.source[this.position] !== "\n")
|
|
398
|
-
text(this.source[this.position], true);
|
|
446
|
+
text(this.source[this.position], true, false, this.position - 1, this.position + 1);
|
|
399
447
|
else
|
|
400
448
|
this.printedNewlineReduction++;
|
|
401
449
|
this.position++;
|
|
@@ -501,8 +549,14 @@ class Lexer {
|
|
|
501
549
|
}
|
|
502
550
|
expansion(parts, quoted) {
|
|
503
551
|
this.budget.admit();
|
|
552
|
+
const spellingStart = this.position;
|
|
504
553
|
const line = this.documentLine ?? this.lineAt(this.position);
|
|
505
554
|
if (this.source[this.position] === "`") {
|
|
555
|
+
if (this.braceReplay && this.position === this.source.length - 1) {
|
|
556
|
+
parts.push({ kind: "text", value: "`", quoted });
|
|
557
|
+
this.position++;
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
506
560
|
this.position++;
|
|
507
561
|
let source = "";
|
|
508
562
|
while (this.position < this.source.length && this.source[this.position] !== "`") {
|
|
@@ -522,6 +576,10 @@ class Lexer {
|
|
|
522
576
|
this.budget.admit();
|
|
523
577
|
parts.push({ kind: "failed-substitution", diagnostic: this.documentSubstitutionError(source, error, true).diagnostic, quoted });
|
|
524
578
|
}
|
|
579
|
+
if (this.documentLine === undefined) {
|
|
580
|
+
this.budget.admit();
|
|
581
|
+
expansionSpellings.set(parts.at(-1), { source: this.source, start: spellingStart, end: this.position });
|
|
582
|
+
}
|
|
525
583
|
return;
|
|
526
584
|
}
|
|
527
585
|
this.position++;
|
|
@@ -641,6 +699,10 @@ class Lexer {
|
|
|
641
699
|
else
|
|
642
700
|
parts.push({ kind: "text", value: "$", quoted });
|
|
643
701
|
}
|
|
702
|
+
if (this.documentLine === undefined) {
|
|
703
|
+
this.budget.admit();
|
|
704
|
+
expansionSpellings.set(parts.at(-1), { source: this.source, start: spellingStart, end: this.position });
|
|
705
|
+
}
|
|
644
706
|
}
|
|
645
707
|
}
|
|
646
708
|
class Parser {
|
|
@@ -978,7 +1040,13 @@ class Parser {
|
|
|
978
1040
|
const entries = [];
|
|
979
1041
|
this.newlines();
|
|
980
1042
|
while (this.current.kind === "word") {
|
|
981
|
-
|
|
1043
|
+
const original = this.advance().word;
|
|
1044
|
+
const entry = compoundEntry(original, this.budget);
|
|
1045
|
+
if (entry.index) {
|
|
1046
|
+
this.budget.admit();
|
|
1047
|
+
compoundEntryWords.set(entry, original);
|
|
1048
|
+
}
|
|
1049
|
+
entries.push(entry);
|
|
982
1050
|
this.newlines();
|
|
983
1051
|
}
|
|
984
1052
|
if (!this.is(")"))
|
|
@@ -1042,6 +1110,12 @@ export function parseShell(source, depth = 0, options = {}) {
|
|
|
1042
1110
|
budget.admit();
|
|
1043
1111
|
return { ...script, ...(warnings.length ? { warnings } : {}) };
|
|
1044
1112
|
}
|
|
1113
|
+
export function parseBraceWord(source, opaque, budget) {
|
|
1114
|
+
budget.admit(source.length + 1);
|
|
1115
|
+
const lexer = new Lexer(budget, source, 0);
|
|
1116
|
+
lexer.braceReplay = opaque;
|
|
1117
|
+
return lexer.word();
|
|
1118
|
+
}
|
|
1045
1119
|
export function* hereDocumentWords(document, line, byteLocale, warnings, budget = new ParseBudget()) {
|
|
1046
1120
|
if (document.quoted) {
|
|
1047
1121
|
budget.admit(2);
|