Skip to content

Commit

Permalink
include ! as a shell word. closes #4386
Browse files Browse the repository at this point in the history
  • Loading branch information
wimglenn committed Nov 14, 2024
1 parent 44be233 commit d59d09f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions examples/playbooks/rule-command-instead-of-shell-pass.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,8 @@
set -x
ls foo?
changed_when: false

- name: Use ! for negation
ansible.builtin.shell:
cmd: "! crontab -l"
changed_when: false
2 changes: 1 addition & 1 deletion src/ansiblelint/rules/command_instead_of_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def matchtask(
return False

jinja_stripped_cmd = self.unjinja(get_cmd_args(task))
return not any(ch in jinja_stripped_cmd for ch in "&|<>;$\n*[]{}?`")
return not any(ch in jinja_stripped_cmd for ch in "&|<>;$\n*[]{}?`!")
return False

def transform(
Expand Down

0 comments on commit d59d09f

Please sign in to comment.