Skip to content

fix: Pass preRun as shell script instead of splitting on whitespace#340

Open
jbinto wants to merge 1 commit into
masterfrom
fix/prerun
Open

fix: Pass preRun as shell script instead of splitting on whitespace#340
jbinto wants to merge 1 commit into
masterfrom
fix/prerun

Conversation

@jbinto
Copy link
Copy Markdown
Contributor

@jbinto jbinto commented Apr 7, 2026

strings.Fields() split multi-line preRun commands into flat tokens, causing only the first command to execute. Wrap the entire script in bash and -euo pipefail so newlines are preserved as command separators, and any failing command fails the entire script immediately.

strings.Fields() split multi-line preRun commands into flat tokens,
causing only the first command to execute. Wrap the entire script in
`bash` and `-euo pipefail` so newlines are preserved as command
separators, and any failing command fails the entire script immediately.
func (d *Docker) RunService(ctx context.Context, serviceName, cmd string) error {
tracker := progress.TrackerFromContext(ctx)
script := strings.TrimSpace(cmd)
shellCmd := []string{"bash", "-c", "set -euo pipefail\n" + script}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the important part, the rest is just helpful logging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant