# @yarnpkg/shell

Latest version **4.1.3** (published 2025-06-03) · BSD-2-Clause license · 0 weekly downloads

## Install

```sh
npm install @yarnpkg/shell
pnpm add @yarnpkg/shell
yarn add @yarnpkg/shell
bun add @yarnpkg/shell
```

Provides the commands `0`, `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `9`, `10`, `11`.

## Health

**Score 50/100 (C)** — status: stable.

Positive: esm support; no vulnerabilities; has provenance; high maintenance score.

Warnings: low downloads; no types.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 4.1.3 |
| Published | 2025-06-03 |
| First published | 2019-09-05 |
| Weekly downloads | 0 |
| License | BSD-2-Clause |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=18.12.0 |
| Dependencies | 8 |
| Unpacked size | 57.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 8110 |
| Maintainers | daniel15, bestander, cpojer, arcanis, yarnbot |

## Links

- npm: https://www.npmjs.com/package/@yarnpkg/shell
- Repository: https://github.com/yarnpkg/berry
- npm.io page: https://npm.io/package/@yarnpkg/shell

## Dependencies (8)

- [chalk](https://npm.io/package/chalk.md) ^4.1.2
- [tslib](https://npm.io/package/tslib.md) ^2.4.0
- [clipanion](https://npm.io/package/clipanion.md) ^4.0.0-rc.2
- [fast-glob](https://npm.io/package/fast-glob.md) ^3.2.2
- [micromatch](https://npm.io/package/micromatch.md) ^4.0.2
- [cross-spawn](https://npm.io/package/cross-spawn.md) ^7.0.3
- [@yarnpkg/fslib](https://npm.io/package/@yarnpkg/fslib.md) ^3.1.2
- [@yarnpkg/parsers](https://npm.io/package/@yarnpkg/parsers.md) ^3.0.3

## Recent versions

- 4.1.3 (latest) — 2025-06-03
- 3.3.0 (v3) — 2023-11-14
- 4.1.2 — 2025-03-01
- 4.1.1 — 2024-11-25
- 4.1.0 — 2024-09-14
- 4.0.2 — 2024-05-02
- 4.0.1 — 2024-05-02
- 4.0.0 — 2023-10-22
- 4.0.0-rc.53 — 2023-10-03
- 4.0.0-rc.52 — 2023-09-29
- 4.0.0-rc.51 — 2023-09-17
- 4.0.0-rc.50 — 2023-08-23
- 4.0.0-rc.49 — 2023-08-17
- 4.0.0-rc.48 — 2023-07-02
- 4.0.0-rc.47 — 2023-06-29
- … 110 more at https://npm.io/package/@yarnpkg/shell/versions

## README

# `@yarnpkg/shell`

A JavaScript implementation of a bash-like shell (we use it in Yarn 2 to provide cross-platform scripting). This package exposes an API that abstracts both the parser and the interpreter; should you only need the parser you can check out `@yarnpkg/parsers`, but you probably won't need it.

## Usage

```ts
import {execute} from '@yarnpkg/shell';

process.exitCode = await execute(`ls "$0" | wc -l`, [process.cwd()]);
```

## Features

- Typechecked
- Portable across systems
- Supports custom JS builtins
- Supports pipes
- Supports glob patterns (**only** for files that exist on the filesystem: `ls *.txt`)
- Supports logical operators
- Supports subshells
- Supports variables
- Supports string manipulators
- Supports argc/argv
- Supports background jobs with color-coded output
- Supports the most classic builtins
- Doesn't necessarily need to access the fs

## Help Wanted

- Full glob support (`mv build/{index.js,index.build.js}`, `echo {foo,bar}`, `FOO=a,b echo {$FOO,x}`)
- More string manipulators

## Non-Goals

- Perfect POSIX compliance (basic scripting is enough for now)
- Multiline scripts (we mostly target one-liners)
- Control structures (same reason)

---
_Source: https://npm.io/package/@yarnpkg/shell · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
