Skip to content

Commit 86012df

Browse files
Fix: Pass -e to sh and bash during command execution (#3065)
## Changes This PR fixes a regression introduced in #2896 where we stopped passing the `-e` flag to the shell, which makes both sh and bash bail out at the first command with a non-zero exit code. ## Why Adding back `-e` keeps the behaviour consistent with the one before #2896 was introduced. ## Tests Newly added regression tests
1 parent 81420d7 commit 86012df

File tree

12 files changed

+43
-3
lines changed

12 files changed

+43
-3
lines changed

.wsignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ experimental/python/docs/images/databricks-logo.svg
1717
# In order to prevent that difference, hello.txt does not have a trailing newline.
1818
acceptance/selftest/record_cloud/volume-io/hello.txt
1919

20+
# error output when artifact build fails contains trailing whitespace:
21+
acceptance/bundle/artifacts/shell/err-bash/output.txt
22+
acceptance/bundle/artifacts/shell/err-sh/output.txt
23+
2024
# "bundle init" has trailing whitespace:
2125
acceptance/bundle/templates-machinery/helpers-error/output.txt
2226

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
artifacts:
2+
my_artifact:
3+
executable: bash
4+
build: |-
5+
echo "hello" > out.shell.txt
6+
echo "world" >> out.shell.txt
7+
false
8+
echo "this should not be printed since bash is run with -e" >> out.shell.txt
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
hello
2+
world
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
>>> [CLI] bundle deploy
3+
Building my_artifact...
4+
Error: build failed my_artifact, error: exit status 1, output:
5+
6+
7+
Exit code: 1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
trace $CLI bundle deploy
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
artifacts:
2+
my_artifact:
3+
executable: sh
4+
build: |-
5+
echo "hello" > out.shell.txt
6+
echo "world" >> out.shell.txt
7+
false
8+
echo "this should not be printed since sh is run with -e" >> out.shell.txt
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
hello
2+
world
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
>>> [CLI] bundle deploy
3+
Building my_artifact...
4+
Error: build failed my_artifact, error: exit status 1, output:
5+
6+
7+
Exit code: 1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
trace $CLI bundle deploy

libs/exec/shell_bash.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type bashShell struct {
1313
func (s bashShell) prepare(command string) (*execContext, error) {
1414
return &execContext{
1515
executable: s.executable,
16-
args: []string{"-c", command},
16+
args: []string{"-ec", command},
1717
}, nil
1818
}
1919

0 commit comments

Comments
 (0)