---
title: "The Bun Shell"
description: "Bun Shell is an experimental embedded shell language and interpreter in Bun (v1.0.24+) that runs cross-platform shell scripts from JavaScript and TypeScript via the `$` tagged template."
url: "https://swe.quest/articles/the-bun-shell-fb66d4232f0f9f2a"
canonical: "https://bun.com/blog/the-bun-shell"
source: "Bun"
published: "2024-01-20"
difficulty: "medium"
kind: "Announcement"
reading_minutes: 4
tags: ["javascript","developer-tools","runtimes"]
---

# The Bun Shell

A post on [Bun](https://swe.quest/sources/bun.md), published 2024-01-20, 4 min read, Announcement. Original: [https://bun.com/blog/the-bun-shell](https://bun.com/blog/the-bun-shell)

## Summary

Bun Shell is an experimental embedded shell language and interpreter in Bun (v1.0.24+) that runs cross-platform shell scripts from JavaScript and TypeScript via the \`$\` tagged template. It targets the platform differences that push npm projects toward polyfill packages like rimraf, cross-env and which, as well as the roughly 7ms cost of spawning bash or sh for each command. Template variables are escaped to prevent injection, and scripts can redirect and pipe to and from Buffers, Responses and files, with builtins like cd, echo and rm. It will power package.json scripts in Bun for Windows.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [JavaScript](https://swe.quest/tags/javascript.md) (Languages)
- [Developer tools](https://swe.quest/tags/developer-tools.md) (Engineering practices)
- [Runtimes & VMs](https://swe.quest/tags/runtimes.md) (Compilers & runtimes)

## Prerequisites

- JavaScript tagged templates ([easy posts on JavaScript](https://swe.quest/tags/javascript.md?difficulty=easy))
- shell scripting basics

## Keywords

Bun, Bun Shell, rimraf, cross-env, npm

## Related posts

- [Bun v1.0.24](https://swe.quest/articles/bun-v1-0-24-b6bb723c8a51261e.md): Bun · 2024-01-20 · Medium · 3 min read · JavaScript, Runtimes & VMs
  Bun v1.0.24 introduces Bun Shell, an experimental embedded shell language and interpreter for running cross-platform shell scripts from JavaScript and TypeScript via the $ template tag, with interop for fetch responses, files and line-by-line output.
- [Bun v1.1.5](https://swe.quest/articles/bun-v1-1-5-2380de858855c125.md): Bun · 2024-04-26 · Medium · 11 min read · JavaScript, Runtimes & VMs, Build systems, Developer tools
  Bun v1.1.5 adds cross-compilation of standalone executables via \`bun build --compile --target\` (Linux x64/arm64, Windows x64, macOS arm64), so CI can build binaries for every platform from one machine.
- [Bun v1.0.32](https://swe.quest/articles/bun-v1-0-32-1109f83c2797523f.md): Bun · 2024-03-17 · Medium · 4 min read · JavaScript, Runtimes & VMs, Debugging
  Bun v1.0.32 fixes 13 bugs, several of them regressions from the I/O rewrite in v1.0.31 done in preparation for Windows support. bun install could hang in GitHub Actions because the active lifecycle-script counter was never decremented. --frozen-lockfile and --production still installed packages, and Bun Shell hung on && and || because a file descriptor was left open.
- [Bun 1.1](https://swe.quest/articles/bun-1-1-d019ca09ea7e158e.md): Bun · 2024-04-01 · Medium · 28 min read · JavaScript, Runtimes & VMs, Developer tools, Performance engineering
  Bun 1.1 adds Windows 10+ support, passing 98% of the macOS/Linux test suite, and reports \`bun install\` 18x faster than yarn and 30x faster than npm on Windows.
- [Bun v1.0.12](https://swe.quest/articles/bun-v1-0-12-7e77f90bbca6622e.md): Bun · 2023-11-16 · Medium · 12 min read · JavaScript, Runtimes & VMs, Testing, Developer tools
  Bun v1.0.12 fixes 24 bugs and adds \`bun -e\` for evaluating inline scripts (with TypeScript, JSX and top-level await), \`--env-file\` for choosing which .env files to load, \`server.url\`, \`import.meta.env\`, and \`expect.unreachable()\` in bun:test.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
