Bash tool incorrectly escapes ! characters

Resolved 💬 2 comments Opened Jan 11, 2026 by r00k Closed Jan 11, 2026

Description

The Bash tool auto-escapes ! characters with backslashes, even inside single-quoted strings where bash would not perform history expansion.

Reproduction

echo 'Attendee.find_or_create_by!(email: "test")'

Expected output:

Attendee.find_or_create_by!(email: "test")

Actual output:

Attendee.find_or_create_by\!(email: "test")

Impact

This breaks Ruby bang methods (save!, create!, find_or_create_by!, etc.) when trying to run inline Ruby code:

bundle exec rails runner 'Attendee.find_or_create_by!(email: "test@test.com") { |a| a.name = "Test" }'

Results in:

syntax error, unexpected backslash
Attendee.find_or_create_by\!(email: "test@test.com") { |...
                          ^

Workaround

Write Ruby code to a temp file first, then run bundle exec rails runner /tmp/script.rb.

View original on GitHub ↗

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