Shell
run: executes a command or a script in a shell on the machine that runs the step. It is the default step type: a step with run: and no action: is a shell step.
Use action: exec when arguments must reach the program exactly as written, with no shell parsing. Use Docker to run the command in a container.
Basic Usage
steps:
- id: hello
run: echo "Hello from $(hostname)"The shell receives the line as one command, so pipes, redirects, $VAR, and $(...) work as in a terminal. The step fails when the shell exits with a non-zero code. Stdout and stderr appear in the step log of the run.
Run Several Commands
A list runs its entries one after another. Each entry starts a new shell, and the step stops at the first entry that fails.
working_dir: .
steps:
- id: checks
run:
- ./scripts/lint.sh
- ./scripts/test.shEntries do not share shell state: a cd, export, or variable in one entry is gone in the next. Use a script when lines depend on each other.
Run a Script
A multi-line run: runs as one script, so cd, variables, functions, and control flow carry across lines.
working_dir: .
steps:
- id: build
run: |
cd app
npm ci
npm run buildWhen the first character of the script starts a shebang and the step does not set with.shell, the shebang interpreter runs the script:
steps:
- id: report
run: |
#!/usr/bin/env python3
import platform
print("python", platform.python_version())with.shell names the interpreter directly, and it wins over a shebang:
steps:
- id: report
run: |
import sys
print(sys.version)
with:
shell: python3Dagu writes the script to a temporary file and deletes it when the step ends. Do not depend on the script's path, name, or $0; use working_dir or DAG_RUN_WORK_DIR when you need a stable location.
Choose a Shell
Set shell at the DAG level for every step, and with.shell on a step to override it:
working_dir: .
shell: ["/bin/bash", "-e", "-u"]
steps:
- id: build
run: make build
- id: notes
run: Write-Output "release notes"
with:
shell: pwshDagu picks the first shell that is set:
- Step
with.shell(withwith.shell_args). - DAG
shell(with DAGshell_args). - Server setting
default_shellor theDAGU_DEFAULT_SHELLenvironment variable. - Platform default:
$SHELL, thenshon macOS and Linux;pwsh, thenpowershell, thencmdon Windows.
A shell value is a string split on spaces ("bash -e") or an array (["bash", "-e"]). Use the array form when an argument contains spaces. Shell values can use references such as ${params.shell} or ${env.SHELL_BIN}, resolved when the step starts.
Dagu adds fail-fast flags for some shell families, such as -e for bash and sh. See macOS and Linux and Windows for the rules of each shell.
Run a Program Without a Shell
action: exec starts the program directly. Each args item reaches it as one argument, so spaces, quotes, *, and | are passed through as data.
steps:
- id: convert
action: exec
with:
command: ffmpeg
args:
- -i
- "input file.mov"
- -vf
- scale=1280:-1
- output.mp4A command without a path separator is looked up in PATH. Use exec when an argument comes from a parameter or another step and must not be interpreted by a shell.
Pass Values Into Commands
Dagu resolves its own references, such as ${params.name}, ${env.NAME}, and ${steps.build.outputs.version}, before the shell starts. Plain $NAME, ${NAME}, $(...), and backticks are left for the shell.
working_dir: .
params:
- region: eu-west-1
steps:
- id: deploy
run: ./deploy.sh --region "${params.region}" --user "$USER"Dagu does not shell-escape resolved values. Quote them for the shell, or pass untrusted text through env or action: exec. See Quoting and Escaping.
Read Standard Input
stdin names a file whose contents the command reads on standard input. A relative path resolves against the step working directory.
steps:
- id: fetch
run: curl -fsS https://example.com/report.csv
- id: count
depends: fetch
stdin: ${fetch.stdout}
run: wc -l${fetch.stdout} is the path of the file that holds the fetch step's stdout. See Standard Input.
Configuration
with fields for a run: step. A run: step accepts no other with fields.
| Field | Required | Default | Description |
|---|---|---|---|
shell | No | DAG shell, then the server default | Shell or interpreter for this step. String or array. Disables shebang detection and the automatic -e. |
shell_args | No | None | Extra arguments for shell, as an array. |
shell_packages | No | None | Packages to provide. Only nix-shell accepts them; see nix-shell. |
with fields for action: exec:
| Field | Required | Default | Description |
|---|---|---|---|
command | Yes | Executable path, or a name looked up in PATH. | |
args | No | None | Arguments, one per item. Strings, numbers, and booleans. |
DAG-level fields:
| Field | Description |
|---|---|
shell | Default shell for every run: step. String or array. |
shell_args | Arguments appended to the DAG shell. |
Other step fields that shell steps use often: working_dir, env, stdin, stdout, stderr, timeout_sec, and retry_policy. See the YAML Specification.
Output
- Stdout and stderr go to the step log. Set
stdout.artifactto also save stdout as a run artifact; see Artifacts. - Outputs: declare names in
outputsand writename=valuelines to$DAGU_OUTPUT_FILE. Later steps read them as${steps.<id>.outputs.<name>}. See Outputs. - Exit code: zero succeeds; any other code fails the step. For a list, the first failing entry decides.
Errors and Limits
- A one-line
run:or a list entry must not contain a line break after references are resolved. Use a multi-line script instead. - Background work started with
&is not part of the step result. Callwaitin the command when the step must include it. - Shell arguments must not carry the command text. Dagu adds the command flag (
-c,-Command,/c) itself; the platform pages list the exact rules. shell_packagesfails with any shell other thannix-shell.directis not a valid shell forrun:. Useaction: exec.
Platform Details
- macOS and Linux: POSIX shells, automatic
-e, nix-shell,PATHunder launchd and systemd. - Windows: PowerShell,
cmd.exe, script encoding.

