bug: Bash tool overquoting !

Resolved 💬 3 comments Opened Oct 25, 2025 by bukzor Closed Oct 29, 2025

Description

The Bash tool escapes ! to \! in command parameters before passing them to
the shell. When the ! is quoted, this corrupts the command.

Reproduction

Bash(seq 3 | jq 'select(. != 2)')

Expected:

● Bash(seq 3 | jq "select(. != 2)")
  ⎿  1
     3

Actual:

● Bash(seq 3 | jq "select(. != 2)")
  ⎿  Error: jq: error: syntax error, unexpected INVALID_CHARACTER (Unix shell quoting issues?) at <top-level>, line 1:
     select(. \!= 2)
     jq: error: try .["field"] instead of .field for unusually named fields at <top-level>, line 1:
     select(. \!= 2)
     jq: 2 compile errors

The command jq receives is select(. \!= 2) instead of select(. != 2).

Impact

Any command using != fails, including:

  • jq filters with inequality operators
  • shell test expressions with [[ $var != value ]]
  • Other tools that use ! in their syntax

Workaround

Use heredoc syntax to bypass the escaping:

seq 3 | jq "$(cat << 'EOF'
select(. != 2)
EOF
)"

Suggested fix

One of:

  1. Remove this DWIM behavior, entirely -- recommended
  2. OR provide an opt-out option -- auto-escape:false
  3. OR "improve" it to notice quoting -- but down this road lies insanity

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗