shell.md
This file
Path
docs/shell.md
38 lines · 1.2 KiB · Markdown
Last changed by
Add user guides (#989)ehmickybefore adoptionbe91ecf
History of this fileTake it
Add user guides (#989)ehmickybefore adoptionbe91ecf
lines 1–38why, 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# 💻 Shell89## Avoiding shells1011In general, [shells](https://en.wikipedia.org/wiki/Shell_(computing)) should be avoided because they are:12- Not cross-platform, encouraging shell-specific syntax.13- Slower, because of the additional shell interpretation.14- Unsafe, potentially allowing [command injection](https://en.wikipedia.org/wiki/Code_injection#Shell_injection) (see the [escaping section](escaping.md#shells)).1516## Specific shell1718```js19import {execa} from 'execa';2021await execa({shell: '/bin/bash'})`npm run "$TASK" && npm run test`;22```2324## OS-specific shell2526When the [`shell`](../readme.md#optionsshell) option is `true`, `sh` is used on Unix and [`cmd.exe`](https://en.wikipedia.org/wiki/Cmd.exe) is used on Windows.2728`sh` and `cmd.exe` syntaxes are very different. Therefore, this is usually not useful.2930```js31await execa({shell: true})`npm run build`;32```3334<hr>3536[**Next**: 📜 Scripts](scripts.md)\37[**Previous**: 💬 Escaping/quoting](escaping.md)\38[**Top**: Table of contents](../readme.md#documentation)