Uh oh!
There was an error while loading. Please reload this page.
Add ShellExecv method - #2862
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
pietern
left a comment
There was a problem hiding this comment.
The PR description talks about env var interpolation, but more importantly, we would need to perform lexical analysis to split a single string into args if we don't use a shell.
Env var interpolation in the script contents is more a side effect than a feature we explicitly need, correct?
Comments are not blocking for merge.
shreyas-goenka
commented
May 14, 2025
@pietern We do want environment variable interpolation since otherwise users will not have a way to configure inputs to their scripts. Good point about the lexical analysis, modified the PR description. |
| // Variant of [Execv] that runs the given script through a shell | ||
| func ShellExecv(content, dir string, env []string) error { | ||
| newOpts, err := shellExecvOpts(content, dir, env) |
There was a problem hiding this comment.
Nit: new in newOpts is no longer accurate
## Why This part of the codebase was missing test coverage. I plan on changing the execution of commands to inline the script content and these tests are required to ensure I don't break anything (relevant discussion: #2862 (comment)) --------- Co-authored-by: Denis Bilenko <denis.bilenko@databricks.com>
## Changes This PR inlines the script content using the `-c` flag in bash and sh instead of passing them in via `-e <file>`. ## Why Based on discussion in #2862 (comment). Getting rid of the temp file means we no longer have to clean up the temporary file created. ## Tests Tests that were added in: #2884
## Changes ShellExecv is a variant of the Execv method that also configures a shell to be used before running the command. ## Why We need it for the scripts section in DABs: #2813. Why: 1. We'll need to perform lexical analysis to figure out where the boundaries for args in the script are. It's better to defer that to a shell. 2. Direct calls to execv do not perform any environment variable interpolation, so we need to go through a shell. This is neat because it provides customers a way to configure inputs to their scripts. 3. Multiline scripts require a shell since, without them, we cannot parse where a command ends. Note: This uses the same priority order for shells as the `artifacts.build` field, that is bash > sh > powershell. ## Tests Unit test. Also acceptance tests in #2813
## Why This part of the codebase was missing test coverage. I plan on changing the execution of commands to inline the script content and these tests are required to ensure I don't break anything (relevant discussion: #2862 (comment)) --------- Co-authored-by: Denis Bilenko <denis.bilenko@databricks.com>
## Changes This PR inlines the script content using the `-c` flag in bash and sh instead of passing them in via `-e <file>`. ## Why Based on discussion in #2862 (comment). Getting rid of the temp file means we no longer have to clean up the temporary file created. ## Tests Tests that were added in: #2884
Changes
ShellExecv is a variant of the Execv method that also configures a shell to be used before running the command.
Why
We need it for the scripts section in DABs: #2813.
Why:
Note: This uses the same priority order for shells as the
artifacts.buildfield, that is bash > sh > powershell.Tests
Unit test. Also acceptance tests in #2813