You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
syntax: printer breaks certain arithmetic expressions #987
((!0)) && echo true || echo false # bash: !0: event not found
I believe this is only true for interactive shells since this syntax triggers history expansion. It's perfectly fine to use it from within a script by the very default, unless you explicitly enable histexpand|history there as well (which I guess is a valid use-case, though I personally prefer to trace the entire thing rather then save a history of it).
hi @mvdan ! i'm new to this project and to contributing to open-source in general. i would like to pick up this issue but am unsure of what needs to be done. would you be able to help me out with how to get started?
@mikeBashStuff It may only be a problem when history expansion is enabled, however, one of the major use cases for zsh support discussed in #120 — and likely also bash support — is to support formatting shell plugins, which will often run in an interactive shell.
Activity
[-]Formatting breaks certain arithmetic expressions[/-][+]syntax: printer breaks certain arithmetic expressions[/+]mvdan commentedon Mar 25, 2023
Thanks for reporting - this does indeed look like a bug. Happy to review a PR, as this one shouldn't be hard to fix.
kiyoon commentedon Apr 15, 2023
I realised in zsh, the expression like this would be treated as
+operation and will make spaces in between, breaking the script.mikeBashStuff commentedon May 13, 2024
I believe this is only true for interactive shells since this syntax triggers history expansion. It's perfectly fine to use it from within a script by the very default, unless you explicitly enable
histexpand|historythere as well (which I guess is a valid use-case, though I personally prefer to trace the entire thing rather then save a history of it).mahadzaryab1 commentedon Aug 16, 2024
hi @mvdan ! i'm new to this project and to contributing to open-source in general. i would like to pick up this issue but am unsure of what needs to be done. would you be able to help me out with how to get started?
mdekstrand commentedon Jul 31, 2025
@mikeBashStuff It may only be a problem when history expansion is enabled, however, one of the major use cases for zsh support discussed in #120 — and likely also bash support — is to support formatting shell plugins, which will often run in an interactive shell.
syntax: add a printer test case for issue #987
syntax: print a space after "!" in arithmetic expressions