Skip to content

Commit

Permalink
Remove one false positive on pipe-fail rule
Browse files Browse the repository at this point in the history
Avoid triggering the rule if pipefail string is used anywhere inside
the script instead of only the first line. We can assume user knew
what to do if it used it.

Fixes: #663
  • Loading branch information
ssbarnea committed Mar 18, 2021
1 parent 0e7e1f2 commit 27f2829
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ansiblelint/rules/ShellWithoutPipefail.py
Expand Up @@ -39,6 +39,6 @@ def matchtask(self, task: Dict[str, Any]) -> Union[bool, str]:

return bool(
self._pipe_re.search(unjinjad_cmd)
and not self._pipefail_re.match(unjinjad_cmd)
and not self._pipefail_re.search(unjinjad_cmd)
and not convert_to_boolean(task['action'].get('ignore_errors', False))
)
6 changes: 6 additions & 0 deletions test/TestShellWithoutPipefail.py
Expand Up @@ -48,6 +48,12 @@
set -eo pipefail
false | cat
- name: pipeline with pipefail not at first line
shell: |
echo foo
set -eo pipefail
false | cat
- name: pipeline without pipefail, ignoring errors
shell: false | cat
ignore_errors: true
Expand Down

0 comments on commit 27f2829

Please sign in to comment.