Repository navigation
dagger shell improvements - #14291
Merged
Merged
Conversation
shykes
marked this pull request as ready for review
September 22, 2026 21:54
shykes
force-pushed
the
shell-exec-command
branch
from
September 22, 2026 21:56
faeed9e to
b9c2d8a
Compare
'dagger shell NAME COMMAND [ARGS...]' runs COMMAND in the named shell, prints its output, and exits with its exit code. Like the interactive shell, each call runs the command again. Add TerminalGroup.exec, which runs the command in the same container that TerminalGroup.run opens. Fixes #14282 Signed-off-by: Solomon Hykes <[email protected]>
'dagger shell NAME -c COMMAND' writes COMMAND to the standard input of the shell's terminal command, instead of running it as exec arguments. If stdin is not a terminal, 'dagger shell NAME' reads the command from it. Positional arguments stay NAME only, and flags parse normally. TerminalGroup.exec now takes stdin instead of args. Signed-off-by: Solomon Hykes <[email protected]>
--copy [PATH=]SOURCE copies a directory into the shell's container. SOURCE is resolved with Address: a local path, a Git URL, or another address. PATH defaults to the working directory. --init COMMAND writes COMMAND to the standard input of the shell's terminal command before the shell opens. Only its changes to the filesystem are kept. Init steps can be cached. Both apply to the interactive shell and to -c. TerminalGroup.run and TerminalGroup.exec get copy and init arguments. Signed-off-by: Solomon Hykes <[email protected]>
Signed-off-by: Solomon Hykes <[email protected]>
If a terminal selection matches more than one target, select the only container, or else the only container in the workspace entrypoint module. So 'dagger shell' and 'dagger shell -c' work without a pattern. Fixes #14281 Also simplify: - Directory.Terminal and terminal targets share one container helper. - Container.WithTerminalDefaults replaces two copies of the default terminal command logic. - TerminalSetupArgs is used directly by the schema and core. - terminalType replaces supportsTerminal and the type switches. - Evaluate the terminal container once. - Show the stdin message only when stderr is a terminal. - Merge the non-interactive integration tests. Signed-off-by: Solomon Hykes <[email protected]>
-c COMMAND now runs the terminal command with '-c COMMAND', as sh does, so the command can read stdin: 'cat f | dagger shell -c "cat -n"'. Without -c, a piped or redirected stdin is the script. Terminals and other devices, such as /dev/null, are not read. Empty scripts fail. TerminalGroup.exec takes args to append to the terminal command, and stdin. Init steps also use -c. Also: - Mount /src read-write for directory shells, so --copy and --init can change it. Directory.terminal stays read-only. - Add a 'dagger shell -l' hint when no default shell is found. - Test the default selection, directory targets, stdin, and failed init steps. Signed-off-by: Solomon Hykes <[email protected]>
Signed-off-by: Solomon Hykes <[email protected]>
shykes
force-pushed
the
shell-exec-command
branch
from
September 22, 2026 22:43
b9c2d8a to
8a8794a
Compare
Signed-off-by: Solomon Hykes <[email protected]>
Signed-off-by: Solomon Hykes <[email protected]>
vito
approved these changes
Sep 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Various improvements to
dagger shelldagger shell [-c COMMAND]Execute a command in the shell and return (non-interactive). Great for agents. You can also pipe the command into stdin.
Fixes #10489.
dagger shell [--copy]Copy a directory into the container.
dagger shell [--init]Run an init shell command in the container.
Default shell
Without a pattern, open the only container, or else the only container in the entrypoint module.
Fixes #14281
API changes
TerminalGroup.runandexecnow select the default target when the selection matches more than one target, instead of returning an error.