@wonderwhy-er/desktop-commander 0.3.2-alpha.3 → 0.3.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/dist/command-manager.d.ts +4 -4
- package/dist/command-manager.js +58 -21
- package/dist/ui/config-editor/config-editor-runtime.js +80 -61
- package/dist/ui/file-preview/preview-runtime.js +226 -215
- package/dist/utils/brace-expansion.d.ts +6 -1
- package/dist/utils/brace-expansion.js +33 -12
- package/dist/utils/cmd-commands.d.ts +2 -2
- package/dist/utils/cmd-commands.js +57 -9
- package/dist/utils/command-reading.d.ts +17 -3
- package/dist/utils/command-reading.js +8 -1
- package/dist/utils/command-wrappers.d.ts +3 -3
- package/dist/utils/command-wrappers.js +37 -14
- package/dist/utils/inline-shells.d.ts +5 -2
- package/dist/utils/inline-shells.js +30 -10
- package/dist/utils/posix-commands.d.ts +5 -2
- package/dist/utils/posix-commands.js +68 -32
- package/dist/utils/posix-shell-capabilities.d.ts +8 -0
- package/dist/utils/posix-shell-capabilities.js +120 -0
- package/dist/utils/powershell-commands.d.ts +2 -1
- package/dist/utils/powershell-commands.js +54 -6
- package/dist/utils/shell-script-files.d.ts +5 -1
- package/dist/utils/shell-script-files.js +38 -19
- package/dist/utils/shell.d.ts +4 -3
- package/dist/utils/shell.js +9 -5
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/dist/bootstrap.js.map +0 -1
- package/dist/command-manager.js.map +0 -1
- package/dist/config-field-definitions.js.map +0 -1
- package/dist/config-manager.js.map +0 -1
- package/dist/config-recovery.js.map +0 -1
- package/dist/config.js.map +0 -1
- package/dist/custom-stdio.js.map +0 -1
- package/dist/error-handlers.js.map +0 -1
- package/dist/handlers/edit-search-handlers.js.map +0 -1
- package/dist/handlers/filesystem-handlers.js.map +0 -1
- package/dist/handlers/history-handlers.js.map +0 -1
- package/dist/handlers/index.js.map +0 -1
- package/dist/handlers/process-handlers.js.map +0 -1
- package/dist/handlers/search-answers.js.map +0 -1
- package/dist/handlers/search-handlers.js.map +0 -1
- package/dist/handlers/terminal-handlers.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/npm-scripts/remote.js.map +0 -1
- package/dist/npm-scripts/setup.js.map +0 -1
- package/dist/npm-scripts/uninstall.js.map +0 -1
- package/dist/npm-scripts/verify-ripgrep.js.map +0 -1
- package/dist/remote-device/desktop-commander-integration.js.map +0 -1
- package/dist/remote-device/device-authenticator.js.map +0 -1
- package/dist/remote-device/device.js.map +0 -1
- package/dist/remote-device/diagnostics/device-log.js.map +0 -1
- package/dist/remote-device/diagnostics/redact.js.map +0 -1
- package/dist/remote-device/diagnostics/report.js.map +0 -1
- package/dist/remote-device/diagnostics/upload.js.map +0 -1
- package/dist/remote-device/mqtt/config.js.map +0 -1
- package/dist/remote-device/mqtt/mqtt-enrollment.js.map +0 -1
- package/dist/remote-device/mqtt/mqtt-transport.js.map +0 -1
- package/dist/remote-device/realtime-health-telemetry.js.map +0 -1
- package/dist/remote-device/remote-channel.js.map +0 -1
- package/dist/remote-device/remote-utils.js.map +0 -1
- package/dist/remote-device/rollouts.js.map +0 -1
- package/dist/remote-device/transport-telemetry.js.map +0 -1
- package/dist/search-manager.js.map +0 -1
- package/dist/server.js.map +0 -1
- package/dist/terminal-manager.js.map +0 -1
- package/dist/tools/config.js.map +0 -1
- package/dist/tools/edit.js.map +0 -1
- package/dist/tools/feedback.js.map +0 -1
- package/dist/tools/filesystem.js.map +0 -1
- package/dist/tools/fuzzySearch.js.map +0 -1
- package/dist/tools/fuzzySearchCore.js.map +0 -1
- package/dist/tools/improved-process-tools.js.map +0 -1
- package/dist/tools/mime-types.js.map +0 -1
- package/dist/tools/pdf/extract-images.js.map +0 -1
- package/dist/tools/pdf/index.js.map +0 -1
- package/dist/tools/pdf/lib/pdf2md.js.map +0 -1
- package/dist/tools/pdf/manipulations.js.map +0 -1
- package/dist/tools/pdf/markdown.js.map +0 -1
- package/dist/tools/pdf/utils.js.map +0 -1
- package/dist/tools/process.js.map +0 -1
- package/dist/tools/prompts.js.map +0 -1
- package/dist/tools/schemas.js.map +0 -1
- package/dist/tools/usage.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/ui/config-editor/src/app.js.map +0 -1
- package/dist/ui/config-editor/src/array-modal.js.map +0 -1
- package/dist/ui/config-editor/src/main.js.map +0 -1
- package/dist/ui/contracts.js.map +0 -1
- package/dist/ui/file-preview/shared/preview-file-types.js.map +0 -1
- package/dist/ui/file-preview/src/app.js.map +0 -1
- package/dist/ui/file-preview/src/components/code-viewer.js.map +0 -1
- package/dist/ui/file-preview/src/components/highlighting.js.map +0 -1
- package/dist/ui/file-preview/src/components/html-renderer.js.map +0 -1
- package/dist/ui/file-preview/src/components/markdown-renderer.js.map +0 -1
- package/dist/ui/file-preview/src/directory-controller.js.map +0 -1
- package/dist/ui/file-preview/src/document-layout.js.map +0 -1
- package/dist/ui/file-preview/src/document-outline.js.map +0 -1
- package/dist/ui/file-preview/src/document-workspace.js.map +0 -1
- package/dist/ui/file-preview/src/file-type-handlers.js.map +0 -1
- package/dist/ui/file-preview/src/host/external-actions.js.map +0 -1
- package/dist/ui/file-preview/src/host/selection-context.js.map +0 -1
- package/dist/ui/file-preview/src/image-preview.js.map +0 -1
- package/dist/ui/file-preview/src/main.js.map +0 -1
- package/dist/ui/file-preview/src/markdown/conflict-dialog.js.map +0 -1
- package/dist/ui/file-preview/src/markdown/controller.js.map +0 -1
- package/dist/ui/file-preview/src/markdown/editor.js.map +0 -1
- package/dist/ui/file-preview/src/markdown/linking.js.map +0 -1
- package/dist/ui/file-preview/src/markdown/outline.js.map +0 -1
- package/dist/ui/file-preview/src/markdown/parser.js.map +0 -1
- package/dist/ui/file-preview/src/markdown/preview.js.map +0 -1
- package/dist/ui/file-preview/src/markdown/slugify.js.map +0 -1
- package/dist/ui/file-preview/src/markdown/utils.js.map +0 -1
- package/dist/ui/file-preview/src/model.js.map +0 -1
- package/dist/ui/file-preview/src/panel-actions.js.map +0 -1
- package/dist/ui/file-preview/src/path-utils.js.map +0 -1
- package/dist/ui/file-preview/src/payload-utils.js.map +0 -1
- package/dist/ui/file-preview/src/types.js.map +0 -1
- package/dist/ui/resources.js.map +0 -1
- package/dist/ui/shared/compact-row.js.map +0 -1
- package/dist/ui/shared/escape-html.js.map +0 -1
- package/dist/ui/shared/host-context.js.map +0 -1
- package/dist/ui/shared/tool-bridge.js.map +0 -1
- package/dist/ui/shared/tool-shell.js.map +0 -1
- package/dist/ui/shared/ui-event-tracker.js.map +0 -1
- package/dist/ui/shared/widget-state.js.map +0 -1
- package/dist/utils/ab-test.js.map +0 -1
- package/dist/utils/atomic-write.js.map +0 -1
- package/dist/utils/capture.js.map +0 -1
- package/dist/utils/dockerPrompt.js.map +0 -1
- package/dist/utils/exit-process.js.map +0 -1
- package/dist/utils/feature-flags.js.map +0 -1
- package/dist/utils/files/base.js.map +0 -1
- package/dist/utils/files/binary.js.map +0 -1
- package/dist/utils/files/docx.js.map +0 -1
- package/dist/utils/files/excel.js.map +0 -1
- package/dist/utils/files/factory.js.map +0 -1
- package/dist/utils/files/image.js.map +0 -1
- package/dist/utils/files/index.js.map +0 -1
- package/dist/utils/files/pdf.js.map +0 -1
- package/dist/utils/files/text.js.map +0 -1
- package/dist/utils/fuzzySearchLogger.js.map +0 -1
- package/dist/utils/internal-facts.js.map +0 -1
- package/dist/utils/lazy-package.js.map +0 -1
- package/dist/utils/lineEndingHandler.js.map +0 -1
- package/dist/utils/logger.js.map +0 -1
- package/dist/utils/mcp-ui-ab-test.js.map +0 -1
- package/dist/utils/open-browser.js.map +0 -1
- package/dist/utils/process-detection.js.map +0 -1
- package/dist/utils/process-tree.js.map +0 -1
- package/dist/utils/rename.js.map +0 -1
- package/dist/utils/ripgrep-resolver.js.map +0 -1
- package/dist/utils/shell.js.map +0 -1
- package/dist/utils/system-info.js.map +0 -1
- package/dist/utils/terminal-timestamps.js.map +0 -1
- package/dist/utils/toolHistory.js.map +0 -1
- package/dist/utils/trackTools.js.map +0 -1
- package/dist/utils/unsupportedParams.js.map +0 -1
- package/dist/utils/usageTracker.js.map +0 -1
- package/dist/utils/welcome-onboarding.js.map +0 -1
- package/dist/utils/withTimeout.js.map +0 -1
- package/dist/version.js.map +0 -1
|
@@ -11,6 +11,11 @@ export interface WordChar {
|
|
|
11
11
|
}
|
|
12
12
|
/** The most words of one expansion the check reads; past that it gives up rather than check part of it */
|
|
13
13
|
export declare const MAX_BRACE_WORDS = 1000;
|
|
14
|
+
/** Default calls retain the historical reading; native capabilities select one range grammar. */
|
|
15
|
+
export type BraceSemantics = 'legacy' | 'bash3' | 'bash5.2' | 'zsh';
|
|
16
|
+
export interface BraceOptions {
|
|
17
|
+
semantics?: BraceSemantics;
|
|
18
|
+
}
|
|
14
19
|
/** Characters that are all text: a quoted part of a word, or a part with no brace syntax in it */
|
|
15
20
|
export declare function quotedChars(text: string): WordChar[];
|
|
16
21
|
/** Characters as written outside quotes, where a backslash makes the character after it text */
|
|
@@ -22,4 +27,4 @@ export declare function unquotedChars(text: string): WordChar[];
|
|
|
22
27
|
* MAX_BRACE_STEPS steps it gives null, and the reader takes the command as
|
|
23
28
|
* unreadable.
|
|
24
29
|
*/
|
|
25
|
-
export declare function braceWords(chars: WordChar[]): string[] | null;
|
|
30
|
+
export declare function braceWords(chars: WordChar[], { semantics }?: BraceOptions): string[] | null;
|
|
@@ -41,9 +41,9 @@ export function unquotedChars(text) {
|
|
|
41
41
|
* MAX_BRACE_STEPS steps it gives null, and the reader takes the command as
|
|
42
42
|
* unreadable.
|
|
43
43
|
*/
|
|
44
|
-
export function braceWords(chars) {
|
|
44
|
+
export function braceWords(chars, { semantics = 'legacy' } = {}) {
|
|
45
45
|
const words = [];
|
|
46
|
-
const steps = { left: MAX_BRACE_STEPS };
|
|
46
|
+
const steps = { left: MAX_BRACE_STEPS, semantics };
|
|
47
47
|
let read = 0;
|
|
48
48
|
try {
|
|
49
49
|
for (const word of expand(chars, steps)) {
|
|
@@ -91,8 +91,9 @@ function* expand(chars, steps) {
|
|
|
91
91
|
/** The words that replace the braces, in order: each piece between the commas, expanded, or the sequence */
|
|
92
92
|
function* middles(chars, brace, steps) {
|
|
93
93
|
if ('text' in brace) {
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
// A generated backslash removed by Bash3/5.2 still keeps its empty argument after quote removal.
|
|
95
|
+
for (const text of sequence(brace.text, steps))
|
|
96
|
+
yield { text, quoted: text === '' };
|
|
96
97
|
return;
|
|
97
98
|
}
|
|
98
99
|
const bounds = [brace.open, ...brace.commas, brace.close];
|
|
@@ -110,6 +111,7 @@ const LETTERS = /^([A-Za-z])\.\.([A-Za-z])(?:\.\.([-+]?\d+))?$/;
|
|
|
110
111
|
*/
|
|
111
112
|
function findBrace(chars, steps) {
|
|
112
113
|
take(steps, chars.length);
|
|
114
|
+
const { semantics } = steps;
|
|
113
115
|
for (let open = 0; open < chars.length; open++) {
|
|
114
116
|
if (!isSyntax(chars[open], '{'))
|
|
115
117
|
continue;
|
|
@@ -138,32 +140,51 @@ function findBrace(chars, steps) {
|
|
|
138
140
|
return { open, close, commas };
|
|
139
141
|
const inside = chars.slice(open + 1, close);
|
|
140
142
|
const text = textOf(inside);
|
|
141
|
-
|
|
143
|
+
const range = NUMBERS.exec(text) ?? LETTERS.exec(text);
|
|
144
|
+
if (semantics === 'zsh' && range && (range[1].startsWith('+') || range[2].startsWith('+')))
|
|
145
|
+
continue;
|
|
146
|
+
if (semantics === 'zsh' && range?.[3] !== undefined
|
|
147
|
+
&& (range[3].startsWith('+') || LETTERS.test(text)))
|
|
148
|
+
continue;
|
|
149
|
+
if (inside.every((c) => !c.quoted) && range && !(semantics === 'bash3' && range[3] !== undefined)) {
|
|
142
150
|
return { open, close, text };
|
|
151
|
+
}
|
|
143
152
|
}
|
|
144
153
|
return null;
|
|
145
154
|
}
|
|
146
155
|
/** The words of a {1..10}, {01..10..2} or {a..e} sequence (findBrace has matched its text) */
|
|
147
|
-
function* sequence(text) {
|
|
156
|
+
function* sequence(text, { semantics }) {
|
|
148
157
|
const numbers = NUMBERS.exec(text);
|
|
149
158
|
if (numbers) {
|
|
150
159
|
const [, first, last, increment] = numbers;
|
|
160
|
+
if (semantics === 'zsh' && increment !== undefined && Number(increment) === 0) {
|
|
161
|
+
yield text;
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
151
164
|
// Match bash: a leading zero (after -, not +) pads to the longer endpoint's width, including its sign.
|
|
152
|
-
|
|
165
|
+
let width = semantics !== 'bash3' && (/^-?0\d/.test(first) || /^-?0\d/.test(last))
|
|
166
|
+
? Math.max(first.length, last.length) : 0;
|
|
167
|
+
// Zsh takes the width from the first padded endpoint, even across a sign change.
|
|
168
|
+
if (semantics === 'zsh' && width)
|
|
169
|
+
width = /^-?0\d/.test(first) ? first.length : last.length;
|
|
153
170
|
const pad = (n) => (n < 0 ? '-' + String(-n).padStart(width - 1, '0') : String(n).padStart(width, '0'));
|
|
154
|
-
for (const n of range(Number(first), Number(last), increment))
|
|
171
|
+
for (const n of range(Number(first), Number(last), { increment, semantics }))
|
|
155
172
|
yield pad(n);
|
|
156
173
|
return;
|
|
157
174
|
}
|
|
158
175
|
const [, first, last, increment] = LETTERS.exec(text);
|
|
159
|
-
for (const n of range(first.charCodeAt(0), last.charCodeAt(0), increment)) {
|
|
160
|
-
//
|
|
161
|
-
if (n
|
|
176
|
+
for (const n of range(first.charCodeAt(0), last.charCodeAt(0), { increment, semantics })) {
|
|
177
|
+
// Bash3/5.2 remove the generated backslash after expansion; Bash5.3 omits its whole word.
|
|
178
|
+
if (n === 0x5c && (semantics === 'bash3' || semantics === 'bash5.2'))
|
|
179
|
+
yield '';
|
|
180
|
+
if (n !== 0x5c || semantics === 'zsh')
|
|
162
181
|
yield String.fromCharCode(n);
|
|
163
182
|
}
|
|
164
183
|
}
|
|
165
184
|
/** from, from ± step, … as far as to, in either direction; bash takes a missing or zero step as 1 */
|
|
166
|
-
function* range(from, to, increment) {
|
|
185
|
+
function* range(from, to, { increment, semantics }) {
|
|
186
|
+
if (semantics === 'zsh' && Number(increment) < 0)
|
|
187
|
+
[from, to] = [to, from];
|
|
167
188
|
const size = Math.abs(Number(increment ?? 1)) || 1;
|
|
168
189
|
const step = from <= to ? size : -size;
|
|
169
190
|
for (let n = from; Math.abs(n - from) <= Math.abs(to - from); n += step)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { CommandReading } from './command-reading.js';
|
|
1
|
+
import type { CommandReadOptions, CommandReading } from './command-reading.js';
|
|
2
2
|
/** Reads a command for cmd */
|
|
3
|
-
export declare function readCmdCommands(command: string): Promise<CommandReading>;
|
|
3
|
+
export declare function readCmdCommands(command: string, { cmdDelayedExpansion }?: CommandReadOptions): Promise<CommandReading>;
|
|
@@ -1,4 +1,41 @@
|
|
|
1
|
-
|
|
1
|
+
/** Percent expansion can span a substitution delimiter, but must start in the executable to change its name. */
|
|
2
|
+
function hasPercentVariable(text, { startsBefore = text.length } = {}) {
|
|
3
|
+
const variable = /%[^%\s]+%/.exec(text);
|
|
4
|
+
return variable !== null && variable.index < startsBefore;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* In explicitly enabled delayed expansion, !VAR! is runtime information
|
|
8
|
+
* rather than a literal program we can claim to have checked.
|
|
9
|
+
* Unquoted carets were removed while tokenizing. A remaining caret protects
|
|
10
|
+
* the next character and interrupts a variable name, as in "!literal^!".
|
|
11
|
+
*/
|
|
12
|
+
function hasDelayedVariable(value, { startsBefore = value.length } = {}) {
|
|
13
|
+
let opening = -1;
|
|
14
|
+
for (let i = 0; i < value.length; i++) {
|
|
15
|
+
if (value[i] === '^') {
|
|
16
|
+
opening = -1;
|
|
17
|
+
i++;
|
|
18
|
+
}
|
|
19
|
+
else if (value[i] === '!') {
|
|
20
|
+
if (opening >= 0 && opening < startsBefore && i > opening + 1)
|
|
21
|
+
return true;
|
|
22
|
+
opening = i;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
/** CMD consumes a caret layer in the executable word even within double quotes. */
|
|
28
|
+
function commandWordValue(text) {
|
|
29
|
+
let value = '';
|
|
30
|
+
for (let i = 0; i < text.length; i++) {
|
|
31
|
+
if (text[i] === '^' && i + 1 < text.length)
|
|
32
|
+
value += text[++i];
|
|
33
|
+
else if (text[i] !== '"')
|
|
34
|
+
value += text[i];
|
|
35
|
+
}
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
function tokenize(text, { cmdDelayedExpansion = 'unknown' }) {
|
|
2
39
|
const tokens = [];
|
|
3
40
|
let i = 0;
|
|
4
41
|
while (i < text.length) {
|
|
@@ -70,7 +107,7 @@ function tokenize(text) {
|
|
|
70
107
|
const lead = /^[;,=@]*/.exec(written)[0].length;
|
|
71
108
|
const drive = /^[A-Za-z]:/.test(value.slice(lead));
|
|
72
109
|
const end = ends.find((at) => at.value >= lead && !(drive && value[at.value] === '/'));
|
|
73
|
-
const atRunTime =
|
|
110
|
+
const atRunTime = hasPercentVariable(written) || (cmdDelayedExpansion === 'on' && hasDelayedVariable(value));
|
|
74
111
|
const ending = { nameEnd: end?.value, textEnd: end?.text };
|
|
75
112
|
tokens.push({ kind: 'word', value, text: written, start, atRunTime, lead, ...ending });
|
|
76
113
|
}
|
|
@@ -112,9 +149,10 @@ const afterName = (word) => word.nameEnd === undefined ? '' : word.value.slice(w
|
|
|
112
149
|
/** The same rest as written, without the ; , = (and its ^) the name ends at */
|
|
113
150
|
const writtenAfterName = (word) => word.textEnd === undefined ? '' : word.text.slice(word.textEnd).replace(/^(\^?[;,=])+/, '');
|
|
114
151
|
class CmdReader {
|
|
115
|
-
constructor(tokens, text) {
|
|
152
|
+
constructor(tokens, text, options) {
|
|
116
153
|
this.tokens = tokens;
|
|
117
154
|
this.text = text;
|
|
155
|
+
this.options = options;
|
|
118
156
|
this.position = 0;
|
|
119
157
|
this.commands = [];
|
|
120
158
|
}
|
|
@@ -246,7 +284,7 @@ class CmdReader {
|
|
|
246
284
|
offsets.push(i);
|
|
247
285
|
command += this.text[i];
|
|
248
286
|
}
|
|
249
|
-
const reader = new CmdReader(tokenize(command), command);
|
|
287
|
+
const reader = new CmdReader(tokenize(command, this.options), command, this.options);
|
|
250
288
|
reader.readList(false);
|
|
251
289
|
this.commands.push(...reader.commands.map(found => ({ ...found, start: offsets[found.start] })));
|
|
252
290
|
}
|
|
@@ -288,15 +326,24 @@ class CmdReader {
|
|
|
288
326
|
}
|
|
289
327
|
addCommand(words) {
|
|
290
328
|
const first = words[0];
|
|
291
|
-
const name =
|
|
329
|
+
const name = commandWordValue(first.text.slice(first.lead ?? 0, first.textEnd));
|
|
292
330
|
if (!name && words.length === 1)
|
|
293
331
|
return; // "" alone runs nothing
|
|
294
332
|
const rest = afterName(first);
|
|
295
333
|
const firstWords = rest ? [name, rest] : [name];
|
|
334
|
+
// Executable words and arguments have different caret phases. Keep the
|
|
335
|
+
// argument reading intact and classify the executable's spelling separately.
|
|
336
|
+
// !tool:old=new! starts in the executable even though its substitution spans a name delimiter.
|
|
337
|
+
const nameLength = commandWordValue(first.text.slice(0, first.textEnd)).length;
|
|
338
|
+
const nameAtRunTime = hasPercentVariable(first.text, { startsBefore: first.textEnd })
|
|
339
|
+
|| (this.options.cmdDelayedExpansion === 'on'
|
|
340
|
+
&& hasDelayedVariable(commandWordValue(first.text), { startsBefore: nameLength }));
|
|
341
|
+
const firstWordValues = firstWords.map((word) => (first.atRunTime ? null : word));
|
|
342
|
+
firstWordValues[0] = nameAtRunTime ? null : name;
|
|
296
343
|
this.commands.push({
|
|
297
344
|
name,
|
|
298
345
|
words: [
|
|
299
|
-
...
|
|
346
|
+
...firstWordValues,
|
|
300
347
|
...words.slice(1).map((word) => (word.atRunTime ? null : word.value)),
|
|
301
348
|
],
|
|
302
349
|
written: [
|
|
@@ -305,13 +352,14 @@ class CmdReader {
|
|
|
305
352
|
],
|
|
306
353
|
wordTexts: [...firstWords, ...words.slice(1).map((word) => word.value)],
|
|
307
354
|
start: first.start,
|
|
308
|
-
nameAtRunTime
|
|
355
|
+
nameAtRunTime,
|
|
309
356
|
});
|
|
310
357
|
}
|
|
311
358
|
}
|
|
312
359
|
/** Reads a command for cmd */
|
|
313
|
-
export async function readCmdCommands(command) {
|
|
314
|
-
const
|
|
360
|
+
export async function readCmdCommands(command, { cmdDelayedExpansion = 'unknown' } = {}) {
|
|
361
|
+
const options = { cmdDelayedExpansion };
|
|
362
|
+
const reader = new CmdReader(tokenize(command, options), command, options);
|
|
315
363
|
try {
|
|
316
364
|
reader.readList(false);
|
|
317
365
|
}
|
|
@@ -4,8 +4,22 @@
|
|
|
4
4
|
* PowerShell, cmd). Every reader returns a CommandReading, and checkCommand()
|
|
5
5
|
* in command-manager.ts turns it into a CommandCheck.
|
|
6
6
|
*/
|
|
7
|
+
/** Private inspection state: the arrays hold only the prefix before a bounded expansion failure. */
|
|
8
|
+
export interface ArgumentInspection {
|
|
9
|
+
argumentError?: string;
|
|
10
|
+
}
|
|
11
|
+
/** An input budget failure, handled like unreadable input rather than a server failure. */
|
|
12
|
+
export declare class IncompleteArgumentsError extends Error {
|
|
13
|
+
}
|
|
14
|
+
/** Consumers call this only after their existing rules say they need the argument vector. */
|
|
15
|
+
export declare function requireCompleteArguments(inspection: ArgumentInspection): void;
|
|
16
|
+
/** Explicit CMD delayed expansion; unknown retains the check's prior literal-name policy. */
|
|
17
|
+
export type CmdDelayedExpansion = 'on' | 'off' | 'unknown';
|
|
18
|
+
export interface CommandReadOptions {
|
|
19
|
+
readonly cmdDelayedExpansion?: CmdDelayedExpansion;
|
|
20
|
+
}
|
|
7
21
|
/** One command the shell would run */
|
|
8
|
-
export interface FoundCommand {
|
|
22
|
+
export interface FoundCommand extends ArgumentInspection {
|
|
9
23
|
/**
|
|
10
24
|
* The command's name as the shell reads it, with quotes and escapes removed.
|
|
11
25
|
* In PowerShell it is what the name means there: an alias gives its target
|
|
@@ -17,7 +31,7 @@ export interface FoundCommand {
|
|
|
17
31
|
/**
|
|
18
32
|
* The command's words as the shell reads them, starting with the name as
|
|
19
33
|
* written (before PowerShell gives its meaning). A word known only at run
|
|
20
|
-
* time, such as "$CMD" or "$(date)", is null.
|
|
34
|
+
* time, such as "$CMD" or "$(date)", is null. With argumentError these arrays are only an inspected prefix.
|
|
21
35
|
*/
|
|
22
36
|
words: (string | null)[];
|
|
23
37
|
/**
|
|
@@ -73,6 +87,6 @@ export interface CommandReading {
|
|
|
73
87
|
* method call), which may remove any of them.
|
|
74
88
|
*/
|
|
75
89
|
functions: DefinedFunction[];
|
|
76
|
-
/**
|
|
90
|
+
/** A syntax/name-inspection error, with empty lists. Deferred argument budgets are explicit on their commands. */
|
|
77
91
|
parseError?: string;
|
|
78
92
|
}
|
|
@@ -4,4 +4,11 @@
|
|
|
4
4
|
* PowerShell, cmd). Every reader returns a CommandReading, and checkCommand()
|
|
5
5
|
* in command-manager.ts turns it into a CommandCheck.
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
/** An input budget failure, handled like unreadable input rather than a server failure. */
|
|
8
|
+
export class IncompleteArgumentsError extends Error {
|
|
9
|
+
}
|
|
10
|
+
/** Consumers call this only after their existing rules say they need the argument vector. */
|
|
11
|
+
export function requireCompleteArguments(inspection) {
|
|
12
|
+
if (inspection.argumentError !== undefined)
|
|
13
|
+
throw new IncompleteArgumentsError(inspection.argumentError);
|
|
14
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ArgumentInspection, type FoundCommand } from './command-reading.js';
|
|
2
2
|
/**
|
|
3
3
|
* The commands that run in `shell`: each of `commands`, followed by the
|
|
4
4
|
* programs that the wrappers among them start (for env sudo ls: env, then
|
|
@@ -36,10 +36,10 @@ export declare function shellOptionReadings(program: string, words: (string | nu
|
|
|
36
36
|
* options read in every way, and the shell that reads its texts. Undefined for
|
|
37
37
|
* any other program.
|
|
38
38
|
*/
|
|
39
|
-
export declare function textProgramReadings(program: string, words: (string | null)[]): {
|
|
39
|
+
export declare function textProgramReadings(program: string, words: (string | null)[], inspection?: ArgumentInspection): {
|
|
40
40
|
readings: OptionReadings;
|
|
41
41
|
shell: string;
|
|
42
42
|
arguments?: number[];
|
|
43
43
|
} | undefined;
|
|
44
44
|
/** For a program that runs one command text in the shell it was started from (see SAME_SHELL_PROGRAMS): its options read in every way */
|
|
45
|
-
export declare function sameShellProgramReadings(program: string, words: (string | null)[]): OptionReadings | undefined;
|
|
45
|
+
export declare function sameShellProgramReadings(program: string, words: (string | null)[], inspection?: ArgumentInspection): OptionReadings | undefined;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getShellType, programName } from './shell.js';
|
|
2
|
+
import { requireCompleteArguments } from './command-reading.js';
|
|
2
3
|
/** tmux's commands that start the program after their options (tmux new-session -d sudo ls), by name and alias */
|
|
3
4
|
const TMUX_NEW_SESSION = { letters: 'cefFnstxy', flags: 'AdDEPX' };
|
|
4
5
|
const TMUX_NEW_WINDOW = { letters: 'ceFnt', flags: 'abdEkPS' };
|
|
@@ -372,15 +373,18 @@ export function withStartedPrograms(commands, shell) {
|
|
|
372
373
|
// finds each level's program from every level before it), and another copy adds no answer
|
|
373
374
|
const seen = new Set();
|
|
374
375
|
const add = (command) => {
|
|
375
|
-
|
|
376
|
+
if (command.nameAtRunTime)
|
|
377
|
+
requireCompleteArguments(command);
|
|
378
|
+
const key = JSON.stringify([command.start, command.words, command.written, command.argumentError]);
|
|
376
379
|
if (seen.has(key))
|
|
377
380
|
return;
|
|
378
381
|
seen.add(key);
|
|
379
382
|
running.push(command);
|
|
380
383
|
if (command.nameAtRunTime)
|
|
381
384
|
return;
|
|
382
|
-
for (const { words, written, wordTexts } of startedPrograms(command, shell)) {
|
|
383
|
-
add({ name: words[0] ?? written[0], words, written, wordTexts, start: command.start,
|
|
385
|
+
for (const { words, written, wordTexts, argumentError } of startedPrograms(command, shell)) {
|
|
386
|
+
add({ name: words[0] ?? written[0], words, written, wordTexts, start: command.start,
|
|
387
|
+
nameAtRunTime: words[0] === null, ...(argumentError === undefined ? {} : { argumentError }) });
|
|
384
388
|
}
|
|
385
389
|
};
|
|
386
390
|
commands.forEach(add);
|
|
@@ -389,29 +393,40 @@ export function withStartedPrograms(commands, shell) {
|
|
|
389
393
|
/** The programs a command starts when it is a wrapper: none for any other command */
|
|
390
394
|
function startedPrograms(command, shell) {
|
|
391
395
|
const shellType = getShellType(shell);
|
|
392
|
-
const name = programName(command.name);
|
|
396
|
+
const name = programName(command.name, shellType);
|
|
393
397
|
const { words, written, wordTexts } = command;
|
|
394
|
-
const from = (at) => ({ words: words.slice(at), written: written.slice(at),
|
|
398
|
+
const from = (at) => ({ words: words.slice(at), written: written.slice(at),
|
|
399
|
+
wordTexts: wordTexts.slice(at),
|
|
400
|
+
...(command.argumentError === undefined ? {} : { argumentError: command.argumentError }) });
|
|
395
401
|
// runuser -u starts the program and its arguments directly, without a shell's text parsing.
|
|
396
402
|
if (name === 'runuser') {
|
|
403
|
+
requireCompleteArguments(command);
|
|
397
404
|
const readings = readOptions(words, TEXT_PROGRAMS.get(name).rules);
|
|
398
405
|
return readings.programs.flatMap(({ at }) => at === undefined ? [] : [from(at)]);
|
|
399
406
|
}
|
|
400
407
|
const posix = PROGRAMS.get(name)
|
|
401
408
|
?? (shellType === 'posix' ? POSIX_SHELL_COMMANDS.get(name) : undefined)
|
|
402
|
-
?? (programName(shell) === 'fish' ? FISH_COMMANDS.get(name) : undefined);
|
|
403
|
-
if (posix)
|
|
409
|
+
?? (programName(shell, shellType) === 'fish' ? FISH_COMMANDS.get(name) : undefined);
|
|
410
|
+
if (posix) {
|
|
411
|
+
requireCompleteArguments(command);
|
|
404
412
|
return posixPrograms(command, posix);
|
|
413
|
+
}
|
|
405
414
|
// Its own arguments are in -ArgumentList, a text the check doesn't read, so a program Start-Process starts has only its name
|
|
406
415
|
if (shellType === 'powershell' && name === 'start-process') {
|
|
416
|
+
requireCompleteArguments(command);
|
|
407
417
|
return (command.filePaths ?? []).map(({ word, written }) => ({
|
|
408
418
|
words: [word], written: [written], wordTexts: [word ?? written],
|
|
419
|
+
...(command.argumentError === undefined ? {} : { argumentError: command.argumentError }),
|
|
409
420
|
}));
|
|
410
421
|
}
|
|
411
|
-
if (shellType === 'cmd' && name === 'start')
|
|
422
|
+
if (shellType === 'cmd' && name === 'start') {
|
|
423
|
+
requireCompleteArguments(command);
|
|
412
424
|
return cmdStartProgramsAt(command).map(from);
|
|
413
|
-
|
|
425
|
+
}
|
|
426
|
+
if (shellType === 'cmd' && name === 'call') {
|
|
427
|
+
requireCompleteArguments(command);
|
|
414
428
|
return words.length > 1 ? [from(1)] : [];
|
|
429
|
+
}
|
|
415
430
|
return [];
|
|
416
431
|
}
|
|
417
432
|
/**
|
|
@@ -419,12 +434,14 @@ function startedPrograms(command, shell) {
|
|
|
419
434
|
* can be. env -S puts the words of its text in its own place and reads them as
|
|
420
435
|
* env's words, followed by the words after the text (env -S ls sudo runs ls).
|
|
421
436
|
*/
|
|
422
|
-
function posixPrograms({ words, written, wordTexts }, rules) {
|
|
437
|
+
function posixPrograms({ words, written, wordTexts, argumentError }, rules) {
|
|
423
438
|
// Windows' timeout /t 5 only waits, and GNU's timeout stops with an error at /t, which is no duration
|
|
424
439
|
const first = words[1];
|
|
425
440
|
if (first && rules.noProgramWords?.includes(first.toLowerCase()))
|
|
426
441
|
return [];
|
|
427
|
-
const from = (i, end = words.length) => ({ words: words.slice(i, end),
|
|
442
|
+
const from = (i, end = words.length) => ({ words: words.slice(i, end),
|
|
443
|
+
written: written.slice(i, end), wordTexts: wordTexts.slice(i, end),
|
|
444
|
+
...(argumentError === undefined ? {} : { argumentError }) });
|
|
428
445
|
const after = rules.programAfter;
|
|
429
446
|
if (after) {
|
|
430
447
|
// find -exec sudo rm {} ;: each program runs from the word after -exec up to ;. A word known only at run time
|
|
@@ -463,6 +480,7 @@ function posixPrograms({ words, written, wordTexts }, rules) {
|
|
|
463
480
|
words: [program, ...words.slice(args)],
|
|
464
481
|
written: [at === undefined ? program ?? '' : written[at], ...written.slice(args)],
|
|
465
482
|
wordTexts: [at === undefined ? program ?? '' : wordTexts[at], ...wordTexts.slice(args)],
|
|
483
|
+
...(argumentError === undefined ? {} : { argumentError }),
|
|
466
484
|
}));
|
|
467
485
|
}
|
|
468
486
|
// psexec \\server sudo ls runs sudo on another computer
|
|
@@ -497,6 +515,7 @@ function posixPrograms({ words, written, wordTexts }, rules) {
|
|
|
497
515
|
words: [words[0], ...split.words, ...words.slice(after)],
|
|
498
516
|
written: [written[0], ...split.written, ...written.slice(after)],
|
|
499
517
|
wordTexts: [wordTexts[0], ...split.wordTexts, ...wordTexts.slice(after)],
|
|
518
|
+
...(argumentError === undefined ? {} : { argumentError }),
|
|
500
519
|
}, rules);
|
|
501
520
|
})];
|
|
502
521
|
}
|
|
@@ -551,10 +570,11 @@ export function shellOptionReadings(program, words) {
|
|
|
551
570
|
* options read in every way, and the shell that reads its texts. Undefined for
|
|
552
571
|
* any other program.
|
|
553
572
|
*/
|
|
554
|
-
export function textProgramReadings(program, words) {
|
|
573
|
+
export function textProgramReadings(program, words, inspection = {}) {
|
|
555
574
|
const found = TEXT_PROGRAMS.get(program);
|
|
556
575
|
if (!found)
|
|
557
576
|
return undefined;
|
|
577
|
+
requireCompleteArguments(inspection);
|
|
558
578
|
const readings = readOptions(words, found.rules);
|
|
559
579
|
// A command of the program's own reads its words by its own rules (tmux new 'sudo ls'), and so does each one
|
|
560
580
|
// after a separator (tmux new -d \; new-window 'sudo ls')
|
|
@@ -577,9 +597,12 @@ export function textProgramReadings(program, words) {
|
|
|
577
597
|
return { readings, shell: found.shell, ...argumentsAt };
|
|
578
598
|
}
|
|
579
599
|
/** For a program that runs one command text in the shell it was started from (see SAME_SHELL_PROGRAMS): its options read in every way */
|
|
580
|
-
export function sameShellProgramReadings(program, words) {
|
|
600
|
+
export function sameShellProgramReadings(program, words, inspection = {}) {
|
|
581
601
|
const rules = SAME_SHELL_PROGRAMS.get(program);
|
|
582
|
-
|
|
602
|
+
if (!rules)
|
|
603
|
+
return undefined;
|
|
604
|
+
requireCompleteArguments(inspection);
|
|
605
|
+
return readOptions(words, rules);
|
|
583
606
|
}
|
|
584
607
|
/**
|
|
585
608
|
* Reads a program's options by its rules, in every way they can be read: an
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ShellType } from './shell.js';
|
|
2
|
-
import type
|
|
2
|
+
import { type CmdDelayedExpansion, type FoundCommand } from './command-reading.js';
|
|
3
3
|
/**
|
|
4
4
|
* What a shell started by a command runs, by the shell's own rules for its
|
|
5
5
|
* arguments: a command text (bash -c 'sudo ls', pwsh -Command 'net user',
|
|
@@ -36,6 +36,8 @@ export interface ShellRun {
|
|
|
36
36
|
file?: string | null;
|
|
37
37
|
/** The shell that reads its texts, when it isn't the program itself: sh for su -c's, cmd for runas's command line */
|
|
38
38
|
shell?: string;
|
|
39
|
+
/** A new CMD invocation's explicit mode; absent/unknown never inherits the outer CMD mode. */
|
|
40
|
+
cmdDelayedExpansion?: CmdDelayedExpansion;
|
|
39
41
|
}
|
|
40
42
|
/**
|
|
41
43
|
* What eval (in a POSIX shell) or Invoke-Expression (in PowerShell, also
|
|
@@ -60,5 +62,6 @@ export declare function sameShellTexts(found: FoundCommand, shellType: ShellType
|
|
|
60
62
|
* text in a shell (su -c 'sudo ls'): nothing for any other command. Its kind
|
|
61
63
|
* of shell is taken from its name as found, as checkCommand() takes the
|
|
62
64
|
* reader for a text from the shell it is given.
|
|
65
|
+
* Existing callers may omit context, so preserve their historical program-name readings.
|
|
63
66
|
*/
|
|
64
|
-
export declare function shellRuns(found: FoundCommand): ShellRun;
|
|
67
|
+
export declare function shellRuns(found: FoundCommand, callerShellType?: ShellType): ShellRun;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getShellType, POSIX_SHELLS, programName } from './shell.js';
|
|
2
|
+
import { requireCompleteArguments } from './command-reading.js';
|
|
2
3
|
import { sameShellProgramReadings, shellOptionReadings, textProgramReadings } from './command-wrappers.js';
|
|
3
4
|
/**
|
|
4
5
|
* PowerShell's parameters that take the next word as their value, whatever
|
|
@@ -42,6 +43,7 @@ function isPowerShellParameter(word) {
|
|
|
42
43
|
* counts. bash's --rcfile or --init-file names a file it runs too.
|
|
43
44
|
*/
|
|
44
45
|
function posixShellRuns(found, program) {
|
|
46
|
+
requireCompleteArguments(found);
|
|
45
47
|
return readingsRun(shellOptionReadings(program, found.words), found, { script: true });
|
|
46
48
|
}
|
|
47
49
|
/**
|
|
@@ -51,7 +53,7 @@ function posixShellRuns(found, program) {
|
|
|
51
53
|
* user, a file or a group.
|
|
52
54
|
*/
|
|
53
55
|
function textProgramRuns(found, program) {
|
|
54
|
-
const text = textProgramReadings(program, found.words);
|
|
56
|
+
const text = textProgramReadings(program, found.words, found);
|
|
55
57
|
if (!text)
|
|
56
58
|
return { texts: [] };
|
|
57
59
|
const run = { ...readingsRun(text.readings, found, { script: false }), shell: text.shell };
|
|
@@ -66,9 +68,10 @@ function textProgramRuns(found, program) {
|
|
|
66
68
|
wordTexts: [text.shell, ...at.map(i => found.wordTexts[i])],
|
|
67
69
|
};
|
|
68
70
|
const inner = posixShellRuns(shellWords, text.shell);
|
|
71
|
+
const file = run.file === null ? null : inner.file;
|
|
69
72
|
return {
|
|
70
73
|
...run, texts: [...new Set([...run.texts, ...inner.texts])],
|
|
71
|
-
...(
|
|
74
|
+
...(file === undefined ? {} : { file }),
|
|
72
75
|
};
|
|
73
76
|
}
|
|
74
77
|
/**
|
|
@@ -108,7 +111,9 @@ function readingsRun({ operands, texts, hidden }, { words, wordTexts }, { script
|
|
|
108
111
|
* -Command or -File. Where the check can't tell which word is a value,
|
|
109
112
|
* every reading counts.
|
|
110
113
|
*/
|
|
111
|
-
function powerShellRuns(
|
|
114
|
+
function powerShellRuns(found, program) {
|
|
115
|
+
requireCompleteArguments(found);
|
|
116
|
+
const { words, wordTexts } = found;
|
|
112
117
|
const texts = [];
|
|
113
118
|
// The script files the readings name, and null for a part known only at run time, which may hold any command
|
|
114
119
|
const files = new Set();
|
|
@@ -199,15 +204,27 @@ function cmdQuoteReadings(line, alwaysDropsQuotes) {
|
|
|
199
204
|
* where a word with whitespace in it is in quotes, as PowerShell and Git Bash
|
|
200
205
|
* pass it.
|
|
201
206
|
*/
|
|
202
|
-
function cmdRuns(
|
|
207
|
+
function cmdRuns(found) {
|
|
208
|
+
requireCompleteArguments(found);
|
|
209
|
+
const { words, wordTexts } = found;
|
|
203
210
|
// Each word is a switch or a part of the command, so one known only at run time may hold any command (cmd $opts)
|
|
204
211
|
const noted = words.slice(1).includes(null) ? { file: null } : {};
|
|
205
212
|
let alwaysDropsQuotes = false;
|
|
213
|
+
let cmdDelayedExpansion = 'unknown';
|
|
206
214
|
for (let i = 1; i < wordTexts.length; i++) {
|
|
207
215
|
const word = wordTexts[i];
|
|
208
216
|
if (!word.startsWith('/'))
|
|
209
217
|
break;
|
|
210
218
|
const run = /^((?:\/(?![ckr])[^/]*)*)\/[ckr](.*)$/is.exec(word);
|
|
219
|
+
const switches = run ? run[1] : word;
|
|
220
|
+
if (words[i] === null) {
|
|
221
|
+
cmdDelayedExpansion = 'unknown';
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
for (const match of switches.matchAll(/\/v:(on|off)(?=\/|$)/gi)) {
|
|
225
|
+
cmdDelayedExpansion = match[1].toLowerCase();
|
|
226
|
+
}
|
|
227
|
+
}
|
|
211
228
|
// /s: cmd drops the quotes around the command in every case
|
|
212
229
|
if (/\/s(?:\/|$)/i.test(run ? run[1] : word))
|
|
213
230
|
alwaysDropsQuotes = true;
|
|
@@ -217,9 +234,9 @@ function cmdRuns({ words, wordTexts }) {
|
|
|
217
234
|
if (lineWords.length === 0)
|
|
218
235
|
break;
|
|
219
236
|
const line = lineWords.map((lineWord) => (lineWord === '' || /\s/.test(lineWord) ? `"${lineWord}"` : lineWord)).join(' ');
|
|
220
|
-
return { texts: cmdQuoteReadings(line, alwaysDropsQuotes), ...noted };
|
|
237
|
+
return { texts: cmdQuoteReadings(line, alwaysDropsQuotes), cmdDelayedExpansion, ...noted };
|
|
221
238
|
}
|
|
222
|
-
return { texts: [], ...noted };
|
|
239
|
+
return { texts: [], cmdDelayedExpansion, ...noted };
|
|
223
240
|
}
|
|
224
241
|
/**
|
|
225
242
|
* What eval (in a POSIX shell) or Invoke-Expression (in PowerShell, also
|
|
@@ -240,13 +257,14 @@ function cmdRuns({ words, wordTexts }) {
|
|
|
240
257
|
*/
|
|
241
258
|
export function sameShellTexts(found, shellType) {
|
|
242
259
|
const { name, words, wordTexts } = found;
|
|
243
|
-
const program = programName(name);
|
|
244
|
-
const sameShell = sameShellProgramReadings(program, words);
|
|
260
|
+
const program = programName(name, shellType);
|
|
261
|
+
const sameShell = sameShellProgramReadings(program, words, found);
|
|
245
262
|
if (sameShell) {
|
|
246
263
|
const run = readingsRun(sameShell, found, { script: false });
|
|
247
264
|
return run.texts.includes('!!') ? { texts: [], file: null } : run;
|
|
248
265
|
}
|
|
249
266
|
if (shellType === 'posix' && program === 'eval') {
|
|
267
|
+
requireCompleteArguments(found);
|
|
250
268
|
const from = words[1] === '--' ? 2 : 1;
|
|
251
269
|
return {
|
|
252
270
|
texts: from < words.length ? [wordTexts.slice(from).join(' ')] : [],
|
|
@@ -254,6 +272,7 @@ export function sameShellTexts(found, shellType) {
|
|
|
254
272
|
};
|
|
255
273
|
}
|
|
256
274
|
if (shellType === 'powershell' && program === 'invoke-expression') {
|
|
275
|
+
requireCompleteArguments(found);
|
|
257
276
|
// Where the words that aren't parameter names are; with none, the text comes from the pipeline
|
|
258
277
|
const at = words.flatMap((word, i) => (i > 0 && (word === null || !/^[-\u2013\u2014\u2015]/.test(word)) ? [i] : []));
|
|
259
278
|
// -Command:'net user' (-c: 'net user'): the command without the parameter's name runs the same, and is shorter
|
|
@@ -275,9 +294,10 @@ export function sameShellTexts(found, shellType) {
|
|
|
275
294
|
* text in a shell (su -c 'sudo ls'): nothing for any other command. Its kind
|
|
276
295
|
* of shell is taken from its name as found, as checkCommand() takes the
|
|
277
296
|
* reader for a text from the shell it is given.
|
|
297
|
+
* Existing callers may omit context, so preserve their historical program-name readings.
|
|
278
298
|
*/
|
|
279
|
-
export function shellRuns(found) {
|
|
280
|
-
const program = programName(found.name);
|
|
299
|
+
export function shellRuns(found, callerShellType) {
|
|
300
|
+
const program = programName(found.name, callerShellType);
|
|
281
301
|
switch (getShellType(found.name)) {
|
|
282
302
|
case 'powershell':
|
|
283
303
|
return powerShellRuns(found, program);
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import type { CommandReading } from './command-reading.js';
|
|
2
|
-
/**
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* The caller supplies its actual selected native endpoint; no endpoint or unsupported capability
|
|
4
|
+
* retains the legacy reading exactly. Capability capture happens on import, not after caller changes.
|
|
5
|
+
*/
|
|
6
|
+
export declare function readPosixCommands(command: string, selectedShell?: string): Promise<CommandReading>;
|