-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathexec.ts
666 lines (584 loc) · 22.9 KB
/
exec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
/*
This module is an adoptation of Go's simple and elegant os/exec.Cmd package.
It provides a reliable and simple way to run sub-processes.
The API and semantics prioritize clarity & simplicity over ease.
There are two important members:
class Cmd(command :string, ...args :string[]) implements CmdOptions
Create a new command structure for running a sub-process
function startCmd(command :string, args? :string[], options? :CmdOptions)
Create & start a command. Thin wrapper around new Cmd... with strong TypeScript typings.
----------------------------------------------------------------------------------------------
startCmd examples
Example: Pipe one command's output into another's input:
const [,{stdout:dateout}] = startCmd("date", [], {stdout:"pipe"})
const [cmd, stdio] = startCmd("cat", [], { stdin: dateout, stdout: "inherit" })
await cmd.wait()
----------------------------------------------------------------------------------------------
Cmd examples
Example: Print output of top to stdout
const cmd = new Cmd("top")
cmd.stdout = process.stdout
await cmd.run()
Example: Get output of uname -a
console.log(await (new Cmd("uname", "-a")).output("utf8"))
Example: Provide a buffer for stdin and capture stdout as text
const cmd = new Cmd("tr", "[:lower:]", "[:upper:]")
cmd.stdin = Buffer.from("Hello world\n")
console.log(await cmd.output("utf8"))
Example: Provide a file for stdin and catpure stdout as text
const cmd = new Cmd("tr", "[:upper:]", "[:lower:]")
cmd.stdin = io.createFileReader("jokes.txt")
console.log(await cmd.output("utf8"))
Example: Execute a command in a shell, listing the contents of a directory
const cmd = new Cmd("if [ -d . ]; then ls; fi")
cmd.shell = true
cmd.dir = "~"
console.log(await cmd.output("utf8"))
Example: Pipe one command's output into another's input
const date = new Cmd("date")
date.stdout = "pipe"
const { stdout: dateout } = date.start()
const cmd = new Cmd("cat")
cmd.stdin = dateout
cmd.stdout = process.stdout
await cmd.run()
*/
import * as fs from "fs"
import * as os from "os"
import * as subproc from "child_process"
import { Writable, Readable, PassThrough as PassThroughStream } from "stream"
import * as io from "./io"
import { createTimeout } from "./timeout"
import { repr, expandTildePath, isWindows } from "./util"
import log from "./log"
export interface Pipes<In=io.Writer|null, Out=io.Reader|null, Err=io.Reader|null> {
readonly stdin :In // valid if Cmd.stdin=="pipe"
readonly stdout :Out // valid if Cmd.stdout=="pipe"
readonly stderr :Err // valid if Cmd.stderr=="pipe"
readonly extraFiles :(io.Reader|io.Writer|null)[] // where extraFiles[N]=="pipe"
}
interface CmdOptions {
dir? :string // working directory. If empty, uses current working directory
env? :{[name:string]:string|undefined} // process environment
shell? :boolean | string // run command in the system-default shell
stdin? :Readable | "inherit" | "pipe" | Buffer | io.Reader | null // fd 0
stdout? :Writable | "inherit" | "pipe" | null // fd 1
stderr? :Writable | "inherit" | "pipe" | null // fd 2
extraFiles? :(Readable | "pipe" | null)[] // fd 3...
windowsHide? :boolean
}
// startCmd launches an external command process.
// It's a convenience function around c=new Cmd();c.start() with strengthened TypeScript types.
//
// Form 1/2a: When no stdio options are provided, no pipes are returned
export function startCmd(command :string, args? :string[]) :[Cmd]
export function startCmd(command :string, args :string[], options :CmdOptions & {
stdin?: never,
stdout?: never,
stderr?: never,
extraFiles? :never,
}) :[Cmd]
//
// Form 1/2b: no args
export function startCmd(command :string, options :CmdOptions & {
stdin?: never,
stdout?: never,
stderr?: never,
extraFiles? :never,
}) :[Cmd]
//
// Form 2/2a: When stdio options are provided, the pipe ends and cmd are returned as a tuple:
export function startCmd<
// at least one stdio input is defined
Options extends CmdOptions & (
{ stdin: CmdOptions["stdin"] } |
{ stdout: CmdOptions["stdout"] } |
{ stderr: CmdOptions["stderr"] } |
{ extraFiles: CmdOptions["extraFiles"] }
),
I = Options extends {stdin: "pipe"} ? io.Writer : null,
O = Options extends {stdout:"pipe"} ? io.Reader : null,
E = Options extends {stderr:"pipe"} ? io.Reader : null,
>(
command :string,
args :string[],
options :Options,
) :[Cmd, Pipes<I,O,E>]
//
// Form 2/2b: no args
export function startCmd<
// at least one stdio input is defined
Options extends CmdOptions & (
{ stdin: CmdOptions["stdin"] } |
{ stdout: CmdOptions["stdout"] } |
{ stderr: CmdOptions["stderr"] } |
{ extraFiles: CmdOptions["extraFiles"] }
),
I = Options extends {stdin: "pipe"} ? io.Writer : null,
O = Options extends {stdout:"pipe"} ? io.Reader : null,
E = Options extends {stderr:"pipe"} ? io.Reader : null,
>(
command :string,
options :Options,
) :[Cmd, Pipes<I,O,E>]
//
// Implementation:
export function startCmd(command :string, args? :string[]|CmdOptions, options? :CmdOptions) {
if (!args || !Array.isArray(args)) {
if (args && typeof args == "object") {
options = args as CmdOptions
}
args = []
}
if (!options) {
options = {}
}
const cmd = new Cmd(command, ...args)
for (let k in options) {
;(cmd as any)[k] = (options as any)[k]
}
const cmdio = cmd.start()
if (options && (
"stdin" in options ||
"stdout" in options ||
"stderr" in options ||
"extraFiles" in options
)) {
return [ cmd, cmdio ]
}
return cmd
}
const notStartedError = "process not started"
export type SignalMode = "standard" | "group"
// Cmd represents an external command being prepared or run
export class Cmd implements Required<CmdOptions> {
command :string
args :string[]
dir :string = "" // working directory. If empty, uses current working directory
env :{[name:string]:string|undefined} = {...process.env} // process environment
shell :boolean | string = false // run command in the system-default shell
stdin :Readable | "inherit" | "pipe" | Buffer | io.Reader | null = null // fd 0
stdout :Writable | "inherit" | "pipe" | null = null // fd 1
stderr :Writable | "inherit" | "pipe" | null = null // fd 2
extraFiles :(Readable | "pipe" | null)[] = [] // fd 3...
windowsHide :boolean = true
readonly process :subproc.ChildProcess | null = null // underlying process
readonly promise :Promise<number> // resolves with status code when process exits
readonly running :boolean = false // true while the underlying process is running
readonly pid :number = 0 // pid, valid after start() has been called
readonly exitCode :number = -1
// exit code of the exited process, or -1 if the process hasn't exited or was
// terminated by a signal.
constructor(command :string, ...args :string[]) {
this.command = command
this.args = args
this.promise = Promise.reject(new Error(notStartedError))
this.promise.catch(_=>{}) // avoid uncaught promise
}
// start launches the command process.
// If the process fails to launch, this function throws an error.
// Returns caller's end of I/O pipes. Returns null if no stdio pipes were configured.
// See startCmd() function as an alternative with stronger TypeScript typings.
start() :Pipes|null { return null } // separate impl
// run starts the specified command and waits for it to complete.
// Returns process exit status code.
run(timeout? :number) :Promise<number> {
this.start()
return this.wait(timeout)
}
// output runs the specified command and returns its standard output.
// If the program does not exit with status 0, an error is thrown.
output(encoding :null|undefined, timeout? :number|null) :Promise<Buffer>
output(encoding :BufferEncoding, timeout? :number|null) :Promise<string>
output(encoding? :BufferEncoding|null, timeout? :number|null) :Promise<Buffer|string> {
this.stdout = "pipe"
if (!this.stderr) {
this.stderr = "pipe"
}
const { stdout, stderr } = this.start()!
const stdoutBuf = io.createWriteBuffer()
const stderrBuf = io.createWriteBuffer()
stdout!.stream.on("data", chunk => {
stdoutBuf.push(chunk)
})
if (stderr) {
stderr.stream.on("data", chunk => {
stderrBuf.push(chunk)
})
}
return this.wait(timeout as number || 0).then(exitCode => {
if (exitCode != 0) {
let errstr = ""
const errbuf = stderrBuf.buffer()
try {
errstr = errbuf.toString("utf8")
} catch (_) {
errstr = errbuf.toString("ascii")
}
if (errstr.length > 0) {
errstr = ". stderr output:\n" + errstr
}
throw new Error(`command exited with status ${exitCode}${errstr}`)
}
const buf = stdoutBuf.buffer()
return encoding ? buf.toString(encoding) : buf
})
}
// wait for process to exit, with an optional timeout expressed in milliseconds.
// Returns the exit status. Throws TIMEOUT on timeout.
wait(timeout? :number, timeoutSignal? :Signal) :Promise<number> {
if (timeout === undefined || timeout <= 0) {
return this.promise
}
return this._waitTimeout(timeout, (err, _resolve, reject) => {
log.debug(()=>`${this} wait timeout reached; killing process`)
err.message = "Cmd.wait timeout"
return this.kill(timeoutSignal).then(() => reject(err))
})
}
// signal sends sig to the underlying process and returns true if sending the signal worked.
// mode defaults to "standard"
//
// If the signal is successfully sent (not neccessarily delivered) true is returned.
// If the process is not running, false is returned (no effect.)
// If the process has not been started, an exception is thrown.
// If the signal is not supported by the platform, an exception is thrown.
// If another error occur, like signalling permissions, false is returned.
//
signal(sig :Signal, mode? :SignalMode) :boolean {
const p = this._checkproc()
if (mode == "group") {
// Signalling process groups via negative pid is supported on most POSIX systems.
// This causes subprocesses that the command process may have started to also receive
// the signal.
try {
process.kill(-p.pid, sig)
return true
} catch (_) {
// will fail if the process is not in its own group or if its is already dead.
// fall through to "proc" mode:
}
}
return p.kill(sig)
}
// kill terminates the command by sending signal sig to the process and waiting for it to exit.
// mode defaults to "group".
//
// If the process has not exited within timeout milliseconds, SIGKILL is sent.
// The timeout should be reasonably large to allow well-behaved processed to run atexit code but
// small enough so that an ill-behaved process is killed within a reasonable timeframe.
// If timeout <= 0 then the returned promise will only resolve if and when the process exits,
// which could be never if the process ignores sig.
//
async kill(sig :Signal="SIGTERM", timeout :number=500, mode? :SignalMode) :Promise<number> {
const p = this._checkproc()
if (!this.signal(sig, mode || "group")) {
return p.exitCode || 0
}
if (timeout <= 0) {
return this.promise
}
return this._waitTimeout(timeout, (_, resolve) => {
log.debug(()=>`${this} kill timeout reached; sending SIGKILL`)
p.kill("SIGKILL")
return this.promise.then(resolve)
})
}
toString() :string {
return this.process ? `Cmd[${this.pid}]` : "Cmd"
}
// -------- internal --------
_resolve :(exitStatus:number)=>void = ()=>{}
_reject :(reason?:any)=>void = ()=>{}
_checkproc() :subproc.ChildProcess {
if (!this.process) {
throw new Error(notStartedError)
}
return this.process
}
_rejectAndKill(reason? :any) {
this._reject(reason)
}
_onerror = (err :Error) => {
log.debug(()=>`${this} error:\n${err.stack||err}`)
this._reject(err)
}
_onexit = (code: number, signal: NodeJS.Signals) => {
// run after process exits
const cmd = this as Mutable<Cmd>
log.debug(()=>`${cmd} exited status=${code} signal=${signal}`)
cmd.running = false
if (code === null || signal !== null) {
assert(typeof signal == "string")
cmd.exitCode = -(os.constants.signals[signal] || 1)
} else {
cmd.exitCode = code || 0
}
cmd._resolve(cmd.exitCode)
}
// _waitTimeout starts a timer which is cancelled when the process exits.
// If the timer expires before the process exits, onTimeout is called with a mutable
// TimeoutError that you can pass to reject and a set of promise resolution functions,
// which control the promise returned by this function.
_waitTimeout(
timeout :number,
onTimeout :(
timeoutErr :Error,
resolve: (code?:number)=>void,
reject: (reason?:any)=>void,
)=>Promise<any>,
) {
return new Promise<number>((resolve, reject) => {
let timeoutOccured = false
this.promise.then(exitCode => {
if (!timeoutOccured) {
resolve(exitCode)
}
})
return createTimeout(this.promise, timeout, timeoutErr => {
timeoutOccured = true
// now, even if the process exits and calls cmd._resolve, the timeout-enabled
// promise returned will not resolve. Instead, we call the onTimeout handler
// which can take its sweet time and eventually, when it's done, call either
// resolve or reject.
onTimeout(timeoutErr, resolve as (code?:number)=>void, reject)
})
})
}
}
Cmd.prototype.start = function start(this :Cmd) :Pipes|null {
const cmd = this as Mutable<Cmd>
if (cmd.running) {
throw new Error("start() called while command is running")
}
// reset exit code
cmd.exitCode = -1
// create a new promise
cmd.promise = new Promise<number>((res,rej) => {
cmd._resolve = res
cmd._reject = rej
})
// configure stdin which may be a buffer
let stdin :Readable | "inherit" | "pipe" | null = null
let stdinStreamNeedsPiping :Readable | null = null
if (cmd.stdin instanceof Buffer) {
stdin = "pipe"
} else if (io.isReader(cmd.stdin)) {
if (typeof (cmd.stdin.stream as any).fd == "string") {
// Nodejs' child_process module can handle "Socket" type of streams directly.
// "Socket" really is just the name for a stream around a file descriptor.
stdin = cmd.stdin.stream
} else {
stdin = "pipe"
stdinStreamNeedsPiping = cmd.stdin.stream
}
} else {
stdin = cmd.stdin
}
// spawn a process
const spawnOptions :subproc.SpawnOptions = {
stdio: [
stdin || 'ignore',
(
cmd.stdout === process.stdout ? 1 :
cmd.stdout || 'ignore'
),
(
cmd.stderr === process.stderr ? 2 :
cmd.stderr ? cmd.stderr : 'ignore'
),
...cmd.extraFiles
],
cwd: cmd.dir ? expandTildePath(cmd.dir) : undefined,
env: cmd.env,
shell: cmd.shell,
windowsHide: cmd.windowsHide,
// On non-windows platforms, set detached so that p gets its own process group, allowing us to
// signal its process tree.
// Note that this option has a different meaning on Windows and screws with stdio inheritance.
detached: !isWindows,
}
// log.debug(()=> `exec spawn ${repr(cmd.command)}, ${repr(cmd.args)} ${repr(spawnOptions)}`)
const p = subproc.spawn(cmd.command, cmd.args, spawnOptions)
// This is a bit of a hack, working around an awkward design choice in nodejs' child_process
// module where spawn errors are deliberately delayed until the next runloop iteration.
// The effect of this choice means that we don't know if creating a new process, which is a
// synchronous operation, succeeded until the next runloop frame.
// We have one thing going for us here: p.pid is undefined when spawn failed, so we can
// look at p.pid to know if there will be an error event in the next runoop frame or not, but
// we don't know anything about the error yet; not until the next runloop frame.
// See https://github.com/nodejs/node/blob/v14.12.0/lib/internal/child_process.js#L379-L390
if (p.pid === undefined) {
cmd.process = null
cmd.pid = 0
// guesstimate the actual error by checking status of command file
const err = guessSpawnError(cmd)
cmd._reject(err)
throw err
}
// set process & running state
cmd.running = true
cmd.process = p
cmd.pid = p.pid
// attach event listeners
p.on("exit", cmd._onexit)
p.on('error', cmd._reject)
log.debug(()=>`${cmd} started (${repr(cmd.command)})`)
// stdin buffer?
if (p.stdin) {
if (cmd.stdin instanceof Buffer) {
const r = new PassThroughStream()
r.end(cmd.stdin)
r.pipe(p.stdin)
p.stdin = null
} else if (stdinStreamNeedsPiping) {
stdinStreamNeedsPiping.pipe(p.stdin)
p.stdin = null
}
}
// if there are no pipes, return no pipes
if (!p.stdin && !p.stdout && !p.stderr && p.stdio.length < 4) {
return null
}
// TODO figure out how to make this properly TypeScript typed.
// Ideally the return type of start() should depend on the values of Cmd.std{in,out,err}
// but I can't figure out how to do that with TypeScript, so here we are, casting null to
// a non-null type, asking for trouble. All for the sake of not having to do "!" for every
// call to stdio objects returned from start()...
const cmdio :Pipes = {
stdin: p.stdin ? io.createWriter(p.stdin) : null,
stdout: p.stdout ? io.createReader(p.stdout) : null,
stderr: p.stderr ? io.createReader(p.stderr) : null,
extraFiles: p.stdio.slice(3).map(stream =>
io.isReadableStream(stream) ? io.createReader(stream) :
io.isWritableStream(stream) ? io.createWriter(stream) :
null
),
}
return cmdio
}
function guessSpawnError(cmd :Cmd) :Error {
// guesstimate the actual error by checking status of command file
let code = ""
let msg = "unspecified error"
if (cmd.shell == false) {
try {
fs.accessSync(cmd.dir, fs.constants.R_OK | fs.constants.X_OK)
const st = fs.statSync(cmd.command)
if ((st.mode & fs.constants.S_IFREG) == 0) {
// not a regular file
code = "EACCES"
} else {
// very likely some sort of I/O error
code = "EIO"
}
} catch (err) {
code = err.code || "ENOENT"
}
msg = io.errorCodeMsg(code) || msg
}
if (!code) {
// check dir
try {
fs.accessSync(cmd.dir, fs.constants.R_OK | fs.constants.X_OK)
code = "EIO"
} catch (err) {
code = err.code || "ENOENT"
}
msg = io.errorCodeMsg(code) || msg
if (code) {
msg = msg + "; cmd.dir=" + repr(cmd.dir)
}
}
if (!code) {
code = "UNKNOWN"
}
const e = new Error(`failed to spawn process ${repr(cmd.command)} (${code} ${msg})`)
;(e as any).code = code
return e
}
export type Signal = NodeJS.Signals | number
// this function is never used but here to test the complex typescript types of spawn()
function _TEST_typescript_startCmd() {
{
const _empty1 :[Cmd] =
startCmd("a", [])
const _empty2 :[Cmd] =
startCmd("a", [], { dir: "" })
const ____ :[Cmd,Pipes<null,null,null>] =
startCmd("a", [], { stdin:null, stdout:null, stderr:"inherit" })
const ____2 :[Cmd,Pipes<null,null,null>] =
startCmd("a", [], { stdin:null, stdout:null, stderr:null })
const ____3 :[Cmd,Pipes<null,null,null>] =
startCmd("a", [], { stdin:null })
const ____4 :[Cmd,Pipes<null,null,null>] =
startCmd("a", [], { stdout:null })
const ____5 :[Cmd,Pipes<null,null,null>] =
startCmd("a", [], { stderr:null })
const _extraFiles :[Cmd,Pipes<null,null,null>] =
startCmd("a", [], { extraFiles:[] })
const _p__ :[Cmd,Pipes<io.Writer,null,null>] =
startCmd("a", [], { stdin:"pipe", stdout:null, stderr:null })
const _p__2 :[Cmd,Pipes<io.Writer,null,null>] =
startCmd("a", [], { stdin:"pipe" })
const _pp_ :[Cmd,Pipes<io.Writer,io.Reader,null>] =
startCmd("a", [], { stdin:"pipe", stdout:"pipe", stderr:null })
const _pp_2 :[Cmd,Pipes<io.Writer,io.Reader,null>] =
startCmd("a", [], { stdin:"pipe", stdout:"pipe" })
const _ppp :[Cmd,Pipes<io.Writer,io.Reader,io.Reader>] =
startCmd("a", [], { stdin:"pipe", stdout:"pipe", stderr:"pipe" })
const __pp :[Cmd,Pipes<null,io.Reader,io.Reader>] =
startCmd("a", [], { stdin:null, stdout:"pipe", stderr:"pipe" })
const __pp2 :[Cmd,Pipes<null,io.Reader,io.Reader>] =
startCmd("a", [], { stdout:"pipe", stderr:"pipe" })
const _p_p :[Cmd,Pipes<io.Writer,null,io.Reader>] =
startCmd("a", [], { stdin:"pipe", stdout:null, stderr:"pipe" })
const _p_p2 :[Cmd,Pipes<io.Writer,null,io.Reader>] =
startCmd("a", [], { stdin:"pipe", stderr:"pipe" })
const ___p :[Cmd,Pipes<null,null,io.Reader>] =
startCmd("a", [], { stdin:null, stdout:null, stderr:"pipe" })
const ___p2 :[Cmd,Pipes<null,null,io.Reader>] =
startCmd("a", [], { stderr:"pipe" })
}
// ---- copy of above, but args omitted ----
{
const _empty1 :[Cmd] =
startCmd("a")
const _empty2 :[Cmd] =
startCmd("a", { dir: "" })
const ____ :[Cmd,Pipes<null,null,null>] =
startCmd("a", { stdin:null, stdout:null, stderr:"inherit" })
const ____2 :[Cmd,Pipes<null,null,null>] =
startCmd("a", { stdin:null, stdout:null, stderr:null })
const ____3 :[Cmd,Pipes<null,null,null>] =
startCmd("a", { stdin:null })
const ____4 :[Cmd,Pipes<null,null,null>] =
startCmd("a", { stdout:null })
const ____5 :[Cmd,Pipes<null,null,null>] =
startCmd("a", { stderr:null })
const _extraFiles :[Cmd,Pipes<null,null,null>] =
startCmd("a", { extraFiles:[] })
const _p__ :[Cmd,Pipes<io.Writer,null,null>] =
startCmd("a", { stdin:"pipe", stdout:null, stderr:null })
const _p__2 :[Cmd,Pipes<io.Writer,null,null>] =
startCmd("a", { stdin:"pipe" })
const _pp_ :[Cmd,Pipes<io.Writer,io.Reader,null>] =
startCmd("a", { stdin:"pipe", stdout:"pipe", stderr:null })
const _pp_2 :[Cmd,Pipes<io.Writer,io.Reader,null>] =
startCmd("a", { stdin:"pipe", stdout:"pipe" })
const _ppp :[Cmd,Pipes<io.Writer,io.Reader,io.Reader>] =
startCmd("a", { stdin:"pipe", stdout:"pipe", stderr:"pipe" })
const __pp :[Cmd,Pipes<null,io.Reader,io.Reader>] =
startCmd("a", { stdin:null, stdout:"pipe", stderr:"pipe" })
const __pp2 :[Cmd,Pipes<null,io.Reader,io.Reader>] =
startCmd("a", { stdout:"pipe", stderr:"pipe" })
const _p_p :[Cmd,Pipes<io.Writer,null,io.Reader>] =
startCmd("a", { stdin:"pipe", stdout:null, stderr:"pipe" })
const _p_p2 :[Cmd,Pipes<io.Writer,null,io.Reader>] =
startCmd("a", { stdin:"pipe", stderr:"pipe" })
const ___p :[Cmd,Pipes<null,null,io.Reader>] =
startCmd("a", { stdin:null, stdout:null, stderr:"pipe" })
const ___p2 :[Cmd,Pipes<null,null,io.Reader>] =
startCmd("a", { stderr:"pipe" })
}
}