bash.md
This file
Path
docs/bash.md
894 lines · 15.1 KiB · Markdown
Last changed by
Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058
History of this fileTake it
Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 1–84why, one step back1<picture>2 <source media="(prefers-color-scheme: dark)" srcset="../media/logo_dark.svg">3 <img alt="execa logo" src="../media/logo.svg" width="400">4</picture>5<br>67# 🔍 Differences with Bash and zx89This page describes the differences between [Bash](https://en.wikipedia.org/wiki/Bash_(Unix_shell)), Execa, and [zx](https://github.com/google/zx) (which inspired this feature). Execa intends to be more:10- [Performant](#performance)11- [Cross-platform](#shell): [no shell](shell.md) is used, only JavaScript.12- [Secure](#escaping): no shell injection.13- [Simple](#simplicity): minimalistic API, no [globals](#global-variables), no [binary](#main-binary), no [builtin CLI utilities](#builtin-utilities).14- [Featureful](#simplicity): all Execa features are available ([text lines iteration](#iterate-over-output-lines), [subprocess piping](#piping-stdout-to-another-command), [IPC](#ipc), [transforms](#transforms), [background subprocesses](#background-subprocess), [cancelation](#cancelation), [local binaries](#local-binaries), [cleanup on exit](termination.md#current-process-exit), [interleaved output](#interleaved-output), [forceful termination](termination.md#forceful-termination), and [more](../readme.md#documentation)).15- [Easy to debug](#debugging): [verbose mode](#verbose-mode), [detailed errors](#errors), [messages and stack traces](#cancelation), stateless API.1617## Flexibility1819Unlike shell languages like Bash, libraries like Execa and zx enable you to write scripts with a more featureful programming language (JavaScript). This allows complex logic (such as [parallel execution](#parallel-commands)) to be expressed easily. This also lets you use [any Node.js package](#builtin-utilities).2021## Shell2223The main difference between Execa and zx is that Execa does not require any shell. Shell-specific keywords and features are [written in JavaScript](#variable-substitution) instead.2425This is more cross-platform. For example, your code works the same on Windows machines without Bash installed.2627Also, there is no shell syntax to remember: everything is just plain JavaScript.2829If you really need a shell though, the [`shell`](shell.md) option can be used.3031## Simplicity3233Execa's scripting API mostly consists of only two methods: [`` $`command` ``](shell.md) and [`$(options)`](execution.md#globalshared-options).3435[No special binary](#main-binary) is recommended, no [global variable](#global-variables) is injected: scripts are regular Node.js files.3637Execa is a thin wrapper around the core Node.js [`child_process` module](https://nodejs.org/api/child_process.html). Unlike zx, it lets you use [any of its native features](#background-subprocess): [`pid`](#pid), [IPC](ipc.md), [`unref()`](https://nodejs.org/api/child_process.html#subprocessunref), [`detached`](environment.md#background-subprocess), [`uid`](windows.md#uid-and-gid), [`gid`](windows.md#uid-and-gid), [`cancelSignal`](termination.md#canceling), etc.3839## Modularity4041zx includes many builtin utilities: `fetch()`, `question()`, `sleep()`, `stdin()`, `retry()`, `spinner()`, `chalk`, `fs-extra`, `os`, `path`, `globby`, `yaml`, `minimist`, `which`, Markdown scripts, remote scripts.4243Execa does not include [any utility](#builtin-utilities): it focuses on being small and modular instead. Any Node.js package can be used in your scripts.4445## Performance4647Spawning a shell for every command comes at a performance cost, which Execa avoids.4849Also, [local binaries](#local-binaries) can be directly executed without using `npx`.5051## Debugging5253Subprocesses can be hard to debug, which is why Execa includes a [`verbose`](#verbose-mode) option.5455Also, Execa's error messages and [properties](#errors) are very detailed to make it clear to determine why a subprocess failed. Error messages and stack traces can be set with [`subprocess.kill(error)`](termination.md#error-message-and-stack-trace).5657Finally, unlike Bash and zx, which are stateful (options, current directory, etc.), Execa is [purely functional](#current-directory), which also helps with debugging.5859## Examples6061### Main binary6263```sh64# Bash65bash file.sh66```6768```js69// zx70zx file.js7172// or a shebang can be used:73// #!/usr/bin/env zx74```7576```js77// Execa scripts are just regular Node.js files78node file.js79```8081### Global variables8283```js84// zxImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
line 85why, one step back85await $`npm run build`;Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 86–91why, one step back86```8788```js89// Execa90import {$} from 'execa';91Improve documentation (#1003)ehmickybefore adoptionc8a6ed7
line 92why, one step back92await $`npm run build`;Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 93–100why, one step back93```9495[More info.](execution.md)9697### Command execution9899```sh100# BashImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
line 101why, one step back101npm run buildAdd user guides (#989)ehmickybefore adoptionbe91ecf
lines 102–105why, one step back102```103104```js105// zxImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
line 106why, one step back106await $`npm run build`;Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 107–110why, one step back107```108109```js110// ExecaImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
line 111why, one step back111await $`npm run build`;Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 112–222why, one step back112```113114### Multiline commands115116```sh117# Bash118npm run build \119 --example-flag-one \120 --example-flag-two121```122123```js124// zx125await $`npm run build ${[126 '--example-flag-one',127 '--example-flag-two',128]}`;129```130131```js132// Execa133await $`npm run build134 --example-flag-one135 --example-flag-two`;136```137138[More info.](execution.md#multiple-lines)139140### Concatenation141142```sh143# Bash144tmpDirectory="/tmp"145mkdir "$tmpDirectory/filename"146```147148```js149// zx150const tmpDirectory = '/tmp'151await $`mkdir ${tmpDirectory}/filename`;152```153154```js155// Execa156const tmpDirectory = '/tmp'157await $`mkdir ${tmpDirectory}/filename`;158```159160[More info.](execution.md#concatenation)161162### Variable substitution163164```sh165# Bash166echo $LANG167```168169```js170// zx171await $`echo $LANG`;172```173174```js175// Execa176await $`echo ${process.env.LANG}`;177```178179[More info.](input.md#environment-variables)180181### Escaping182183```sh184# Bash185echo 'one two'186```187188```js189// zx190await $`echo ${'one two'}`;191```192193```js194// Execa195await $`echo ${'one two'}`;196```197198[More info.](escaping.md)199200### Escaping multiple arguments201202```sh203# Bash204echo 'one two' '$'205```206207```js208// zx209await $`echo ${['one two', '$']}`;210```211212```js213// Execa214await $`echo ${['one two', '$']}`;215```216217[More info.](execution.md#multiple-arguments)218219### Subcommands220221```sh222# BashImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
line 223why, one step back223echo "$(npm run build)"Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 224–227why, one step back224```225226```js227// zxImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
lines 228–229why, one step back228const result = await $`npm run build`;229await $`echo ${result}`;Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 230–233why, one step back230```231232```js233// ExecaImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
lines 234–235why, one step back234const result = await $`npm run build`;235await $`echo ${result}`;Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 236–243why, one step back236```237238[More info.](execution.md#subcommands)239240### Serial commands241242```sh243# BashImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
line 244why, one step back244npm run build && npm run testAdd user guides (#989)ehmickybefore adoptionbe91ecf
lines 245–248why, one step back245```246247```js248// zxImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
line 249why, one step back249await $`npm run build && npm run test`;Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 250–253why, one step back250```251252```js253// ExecaImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
lines 254–255why, one step back254await $`npm run build`;255await $`npm run test`;Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 256–261why, one step back256```257258### Parallel commands259260```sh261# BashImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
lines 262–263why, one step back262npm run build &263npm run test &Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 264–267why, one step back264```265266```js267// zxImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
line 268why, one step back268await Promise.all([$`npm run build`, $`npm run test`]);Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 269–272why, one step back269```270271```js272// ExecaImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
line 273why, one step back273await Promise.all([$`npm run build`, $`npm run test`]);Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 274–280why, one step back274```275276### Global/shared options277278```sh279# Bash280options="timeout 5"Improve documentation (#1003)ehmickybefore adoptionc8a6ed7
lines 281–283why, one step back281$options npm run init282$options npm run build283$options npm run testAdd user guides (#989)ehmickybefore adoptionbe91ecf
lines 284–288why, one step back284```285286```js287// zx288const timeout = '5s';Improve documentation (#1003)ehmickybefore adoptionc8a6ed7
lines 289–291why, one step back289await $`npm run init`.timeout(timeout);290await $`npm run build`.timeout(timeout);291await $`npm run test`.timeout(timeout);Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 292–299why, one step back292```293294```js295// Execa296import {$ as $_} from 'execa';297298const $ = $_({timeout: 5000});299Improve documentation (#1003)ehmickybefore adoptionc8a6ed7
lines 300–302why, one step back300await $`npm run init`;301await $`npm run build`;302await $`npm run test`;Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 303–310why, one step back303```304305[More info.](execution.md#globalshared-options)306307### Environment variables308309```sh310# BashImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
line 311why, one step back311EXAMPLE=1 npm run buildAdd user guides (#989)ehmickybefore adoptionbe91ecf
lines 312–316why, one step back312```313314```js315// zx316$.env.EXAMPLE = '1';Improve documentation (#1003)ehmickybefore adoptionc8a6ed7
line 317why, one step back317await $`npm run build`;Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 318–322why, one step back318delete $.env.EXAMPLE;319```320321```js322// ExecaImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
line 323why, one step back323await $({env: {EXAMPLE: '1'}})`npm run build`;Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 324–381why, one step back324```325326[More info.](input.md#environment-variables)327328### Local binaries329330```sh331# Bash332npx tsc --version333```334335```js336// zx337await $`npx tsc --version`;338```339340```js341// Execa342await $`tsc --version`;343```344345[More info.](environment.md#local-binaries)346347### Builtin utilities348349```js350// zx351const content = await stdin();352```353354```js355// Execa356import getStdin from 'get-stdin';357358const content = await getStdin();359```360361### Printing to stdout362363```sh364# Bash365echo example366```367368```js369// zx370echo`example`;371```372373```js374// Execa375console.log('example');376```377378### Silent stderr379380```sh381# BashImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
line 382why, one step back382npm run build 2> /dev/nullAdd user guides (#989)ehmickybefore adoptionbe91ecf
lines 383–386why, one step back383```384385```js386// zxImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
line 387why, one step back387await $`npm run build`.stdio('inherit', 'pipe', 'ignore');Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 388–391why, one step back388```389390```js391// Execa does not print stdout/stderr by defaultImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
line 392why, one step back392await $`npm run build`;Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 393–399why, one step back393```394395### Verbose mode396397```sh398# Bash399set -vImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
line 400why, one step back400npm run buildAdd user guides (#989)ehmickybefore adoptionbe91ecf
lines 401–404why, one step back401```402403```js404// zx >=8Improve documentation (#1003)ehmickybefore adoptionc8a6ed7
line 405why, one step back405await $`npm run build`.verbose();Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 406–412why, one step back406407// or:408$.verbose = true;409```410411```js412// ExecaImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
line 413why, one step back413await $({verbose: 'full'})`npm run build`;Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 414–424why, one step back414```415416Or:417418```419NODE_DEBUG=execa node file.js420```421422Which prints:423424```Improve documentation (#1003)ehmickybefore adoptionc8a6ed7
lines 425–427why, one step back425[19:49:00.360] [0] $ npm run build426Building...427Done.Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 428–457why, one step back428[19:49:00.383] [0] √ (done in 23ms)429```430431[More info.](debugging.md#verbose-mode)432433### Piping stdout to another command434435```sh436# Bash437echo npm run build | sort | head -n2438```439440```js441// zx442await $`npm run build | sort | head -n2`;443```444445```js446// Execa447await $`npm run build`448 .pipe`sort`449 .pipe`head -n2`;450```451452[More info.](pipe.md)453454### Piping stdout and stderr to another command455456```sh457# BashImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
line 458why, one step back458npm run build |& catAdd user guides (#989)ehmickybefore adoptionbe91ecf
lines 459–462why, one step back459```460461```js462// zxImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
line 463why, one step back463const subprocess = $`npm run build`;Add user guides (#989)ehmickybefore adoptionbe91ecf
line 464why, one step back464const cat = $`cat`;Improve documentation (#1003)ehmickybefore adoptionc8a6ed7
lines 465–467why, one step back465subprocess.pipe(cat);466subprocess.stderr.pipe(cat.stdin);467await Promise.all([subprocess, cat]);Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 468–471why, one step back468```469470```js471// ExecaImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
line 472why, one step back472await $({all: true})`npm run build`Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 473–481why, one step back473 .pipe({from: 'all'})`cat`;474```475476[More info.](pipe.md#source-file-descriptor)477478### Piping stdout to a file479480```sh481# BashImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
line 482why, one step back482npm run build > output.txtAdd user guides (#989)ehmickybefore adoptionbe91ecf
lines 483–486why, one step back483```484485```js486// zxImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
lines 487–489why, one step back487import {createWriteStream} from 'node:fs';488489await $`npm run build`.pipe(createWriteStream('output.txt'));Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 490–493why, one step back490```491492```js493// ExecaImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
line 494why, one step back494await $({stdout: {file: 'output.txt'}})`npm run build`;Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 495–498why, one step back495```496497[More info.](output.md#file-output)498Fix passing the same file or stream to both `stdout` and `stderr` (#1004)ehmickybefore adoptionea889c7
lines 499–524why, one step back499### Piping interleaved stdout and stderr to a file500501```sh502# Bash503npm run build &> output.txt504```505506```js507// zx508import {createWriteStream} from 'node:fs';509510const subprocess = $`npm run build`;511const fileStream = createWriteStream('output.txt');512subprocess.pipe(fileStream);513subprocess.stderr.pipe(fileStream);514await subprocess;515```516517```js518// Execa519const output = {file: 'output.txt'};520await $({stdout: output, stderr: output})`npm run build`;521```522523[More info.](output.md#file-output)524Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 525–528why, one step back525### Piping stdin from a file526527```sh528# BashImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
line 529why, one step back529cat < input.txtAdd user guides (#989)ehmickybefore adoptionbe91ecf
lines 530–660why, one step back530```531532```js533// zx534const cat = $`cat`;535fs.createReadStream('input.txt').pipe(cat.stdin);536await cat;537```538539```js540// Execa541await $({inputFile: 'input.txt'})`cat`;542```543544[More info.](input.md#file-input)545546### Iterate over output lines547548```sh549# Bash550while read551do552 if [[ "$REPLY" == *ERROR* ]]553 then554 echo "$REPLY"555 fi556done < <(npm run build)557```558559```js560// zx does not allow proper iteration.561// For example, the iteration does not handle subprocess errors.562```563564```js565// Execa566for await (const line of $`npm run build`) {567 if (line.includes('ERROR')) {568 console.log(line);569 }570}571```572573[More info.](lines.md#progressive-splitting)574575### Errors576577```sh578# Bash communicates errors only through the exit code and stderr579timeout 1 sleep 2580echo $?581```582583```js584// zx585const {586 stdout,587 stderr,588 exitCode,589 signal,590} = await $`sleep 2`.timeout('1s');591// file:///home/me/Desktop/node_modules/zx/build/core.js:146592// let output = new ProcessOutput(code, signal, stdout, stderr, combined, message);593// ^594// ProcessOutput [Error]:595// at file:///home/me/Desktop/example.js:2:20596// exit code: null597// signal: SIGTERM598// at ChildProcess.<anonymous> (file:///home/me/Desktop/node_modules/zx/build/core.js:146:26)599// at ChildProcess.emit (node:events:512:28)600// at maybeClose (node:internal/child_process:1098:16)601// at Socket.<anonymous> (node:internal/child_process:456:11)602// at Socket.emit (node:events:512:28)603// at Pipe.<anonymous> (node:net:316:12)604// at Pipe.callbackTrampoline (node:internal/async_hooks:130:17) {605// _code: null,606// _signal: 'SIGTERM',607// _stdout: '',608// _stderr: '',609// _combined: ''610// }611```612613```js614// Execa615const {616 stdout,617 stderr,618 exitCode,619 signal,620 signalDescription,621 originalMessage,622 shortMessage,623 command,624 escapedCommand,625 failed,626 timedOut,627 isCanceled,628 isTerminated,629 isMaxBuffer,630 // and other error-related properties: code, etc.631} = await $({timeout: 1})`sleep 2`;632// ExecaError: Command timed out after 1 milliseconds: sleep 2633// at file:///home/me/Desktop/example.js:2:20634// at ... {635// shortMessage: 'Command timed out after 1 milliseconds: sleep 2\nTimed out',636// originalMessage: '',637// command: 'sleep 2',638// escapedCommand: 'sleep 2',639// cwd: '/path/to/cwd',640// durationMs: 19.95693,641// failed: true,642// timedOut: true,643// isCanceled: false,644// isTerminated: true,645// isMaxBuffer: false,646// signal: 'SIGTERM',647// signalDescription: 'Termination',648// stdout: '',649// stderr: '',650// stdio: [undefined, '', ''],651// pipedFrom: []652// }653```654655[More info.](errors.md)656657### Exit codes658659```sh660# BashImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
line 661why, one step back661npm run buildAdd user guides (#989)ehmickybefore adoptionbe91ecf
lines 662–666why, one step back662echo $?663```664665```js666// zxImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
line 667why, one step back667const {exitCode} = await $`npm run build`.nothrow();Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 668–672why, one step back668echo`${exitCode}`;669```670671```js672// ExecaImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
line 673why, one step back673const {exitCode} = await $({reject: false})`npm run build`;Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 674–682why, one step back674console.log(exitCode);675```676677[More info.](errors.md#exit-code)678679### Timeouts680681```sh682# BashImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
line 683why, one step back683timeout 5 npm run buildAdd user guides (#989)ehmickybefore adoptionbe91ecf
lines 684–687why, one step back684```685686```js687// zxImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
line 688why, one step back688await $`npm run build`.timeout('5s');Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 689–692why, one step back689```690691```js692// ExecaImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
line 693why, one step back693await $({timeout: 5000})`npm run build`;Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 694–768why, one step back694```695696[More info.](termination.md#timeout)697698### Current filename699700```sh701# Bash702echo "$(basename "$0")"703```704705```js706// zx707await $`echo ${__filename}`;708```709710```js711// Execa712await $`echo ${import.meta.filename}`;713```714715### Current directory716717```sh718# Bash719cd project720```721722```js723// zx724cd('project');725726// or:727$.cwd = 'project';728```729730```js731// Execa732const $$ = $({cwd: 'project'});733```734735[More info.](environment.md#current-directory)736737### Multiple current directories738739```sh740# Bash741pushd project742pwd743popd744pwd745```746747```js748// zx749within(async () => {750 cd('project');751 await $`pwd`;752});753754await $`pwd`;755```756757```js758// Execa759await $({cwd: 'project'})`pwd`;760await $`pwd`;761```762763[More info.](environment.md#current-directory)764765### Background subprocess766767```sh768# BashImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
line 769why, one step back769npm run build &Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 770–777why, one step back770```771772```js773// zx does not allow setting the `detached` option774```775776```js777// ExecaImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
line 778why, one step back778await $({detached: true})`npm run build`;Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 779–874why, one step back779```780781[More info.](environment.md#background-subprocess)782783### IPC784785```sh786# Bash does not allow simple IPC787```788789```js790// zx does not allow simple IPC791```792793```js794// Execa795const subprocess = $({ipc: true})`node script.js`;796797subprocess.on('message', message => {798 if (message === 'ping') {799 subprocess.send('pong');800 }801});802```803804[More info.](ipc.md)805806### Transforms807808```sh809# Bash does not allow transforms810```811812```js813// zx does not allow transforms814```815816```js817// Execa818const transform = function * (line) {819 if (!line.includes('secret')) {820 yield line;821 }822};823824await $({stdout: [transform, 'inherit']})`echo ${'This is a secret.'}`;825```826827[More info.](transform.md)828829### Cancelation830831```sh832# Bash833kill $PID834```835836```js837// zx838subprocess.kill();839```840841```js842// Execa843// Can specify an error message and stack trace844subprocess.kill(error);845846// Or use an `AbortSignal`847const controller = new AbortController();848await $({signal: controller.signal})`node long-script.js`;849```850851[More info.](termination.md#canceling)852853### Interleaved output854855```sh856# Bash prints stdout and stderr interleaved857```858859```js860// zx separates stdout and stderr861const {stdout, stderr} = await $`node example.js`;862```863864```js865// Execa can interleave stdout and stderr866const {all} = await $({all: true})`node example.js`;867```868869[More info.](output.md#interleaved-output)870871### PID872873```sh874# BashImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
line 875why, one step back875npm run build &Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 876–884why, one step back876echo $!877```878879```js880// zx does not return `subprocess.pid`881```882883```js884// ExecaImprove documentation (#1003)ehmickybefore adoptionc8a6ed7
line 885why, one step back885const {pid} = $`npm run build`;Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 886–891why, one step back886```887888[More info.](termination.md#inter-process-termination)889890<hr>891Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058
line 892why, one step back892[**Next**: 🤓 TypeScript](typescript.md)\Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 893–894why, one step back893[**Previous**: 📎 Windows](windows.md)\894[**Top**: Table of contents](../readme.md#documentation)