After hitting this issue relatively often since I started using ripgrep, I finally understood what the exact issue appears to be.
When trying to exclude a given folder from my search paths with the globbing option -g, it fails if the expression string is enclosed with double quotes ("). It works fine with simple quotes ('):
$ rg -g "!thirdparty" test
bash: !thirdparty: event not found
$ rg -g '!thirdparty' test
servers/visual_server.h: RID _make_test_cube();
servers/visual_server.h: RID test_texture;
[...]
I don't know if the issue can be fixed in ripgrep or if it's a limitation of Bash, but I've been using ' and " interchangeably for many years in my shell without notable issues.
Environment:
Edit: Upgraded ripgrep to 0.7.1, same issue (report was originally about 0.6.0).
That is just the way history expansion works in bash. It's similar to $ in that it expands inside double-quotes but not single-quotes. You have four options:
! (\!thirdparty)set +H or adding it to your profilehistchars variable; for example, histchars='%^#' will change it from ! to %Thanks a lot for the detailed answer! I think I'll start using \! for ripgrep, that's something I should easily remember and avoid bad surprise when I pick the wrong quotes.
Closing as it's not a bug, though it might be worth adding a mention to this in the --help output if other shells work similarly - if it's only bash, it's maybe not worth cluttering the docs.
Most helpful comment
That is just the way history expansion works in bash. It's similar to
$in that it expands inside double-quotes but not single-quotes. You have four options:!(\!thirdparty)set +Hor adding it to your profilehistcharsvariable; for example,histchars='%^#'will change it from!to%