Skip to content

Commit eef5502

Browse files
authored
Shell options for deno task (#2855)
1 parent 95754fa commit eef5502

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

runtime/reference/cli/task.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,46 @@ echo data[0-9].csv
565565

566566
The supported glob characters are `*`, `?`, and `[`/`]`.
567567

568+
### Shell options
569+
570+
`deno task` supports shell options in Deno 2.6.6 and above to control glob
571+
expansion and pipeline behavior. By default, `failglob` and `globstar` are
572+
enabled.
573+
574+
- **failglob** - When enabled, globs that don't match any files will cause an
575+
error. Disable with `shopt -u failglob`.
576+
- **globstar** - When enabled, `**` matches zero or more directories. Disable
577+
with `shopt -u globstar`.
578+
- **nullglob** - When enabled, globs that don't match any files expand to
579+
nothing instead of the literal glob pattern. Enable with `shopt -s nullglob`.
580+
- **pipefail** - When enabled, the exit code of a pipeline is the exit code of
581+
the last command to exit with a non-zero status, or zero if all commands exit
582+
successfully. Enable with `set -o pipefail`.
583+
584+
Examples:
585+
586+
```jsonc title="deno.jsonc"
587+
{
588+
"tasks": {
589+
// disable failglob
590+
"task1": "shopt -u failglob && rm -rf *.ts",
591+
// disable failglob and enable nullglob
592+
"task2": "shopt -u failglob && shopt -s nullglob && rm -rf *.ts",
593+
// disable globstar
594+
"task3": "shopt -u globstar && echo **/*.ts",
595+
// enable pipefail
596+
"task4": "set -o pipefail && cat missing.txt | echo 'hello'"
597+
}
598+
}
599+
```
600+
601+
:::note
602+
603+
Shell options do not propagate to `deno task` subprocesses. Each `deno task`
604+
invocation starts with the default options.
605+
606+
:::
607+
568608
## Built-in commands
569609

570610
`deno task` ships with several built-in commands that work the same out of the

0 commit comments

Comments
 (0)