Skip to content

Commit

Permalink
Re-enable bash strict mode on Linux (#1135)
Browse files Browse the repository at this point in the history
  • Loading branch information
DonFreed committed Aug 20, 2021
1 parent c5ba569 commit edadd41
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions snakemake/shell.py
Expand Up @@ -85,6 +85,8 @@ def executable(cls, cmd):
)
cls._process_prefix = "set -euo pipefail; "
cls._win_command_prefix = "-c"
elif os.path.split(cmd)[-1].lower() == "bash":
cls._process_prefix = "set -euo pipefail; "
cls._process_args["executable"] = cmd

@classmethod
Expand Down
12 changes: 12 additions & 0 deletions tests/test_strict_mode/Snakefile
@@ -0,0 +1,12 @@
shell.executable("bash")

rule a:
output:
"test.out"
shell:
"""
echo 'prints 1'
$(exit 1) # Should fail with set -e
echo 'prints 2'
echo 'hello' > {output}
"""
Empty file.
4 changes: 4 additions & 0 deletions tests/tests.py
Expand Up @@ -1286,3 +1286,7 @@ def test_touch_pipeline_with_temp_dir():

def test_all_temp():
run(dpath("test_all_temp"), all_temp=True)


def test_strict_mode():
run(dpath("test_strict_mode"), shouldfail=True)

0 comments on commit edadd41

Please sign in to comment.