$ ag findVersions( src/java/com/google
-bash: syntax error near unexpected token `('
我尝试引用它,逃避它,两者都不合适。
$ ag findVersions\( src/java/com/google
ERR: pcre_compile failed at position 13. Error: missing )
$ ack findVersions\( src/java/com/twitter
Invalid regex 'findVersions(':
Unmatched ( in regex; marked by <-- HERE in m/findVersions( <-- HERE / at /opt/bin/ack line 2989.
答案1
由于第一个参数是正则表达式,因此您必须:转义正则表达式特殊字符,并保护它免受 shell 的影响
ag 'findVersions\(' src/java/com/google