Search code examples
ag

SilverSearcher - Why can I use `--ignore=PATTERN` when documentation says `--ignore PATTERN` without a equal sign?


I had to ignore multiple directories, so I tried

ag --hidden --ignore '.git' --ignore 'plugged' -g ""

But this process of narrating --ignore each time I tried to ignore a directory felt needless. So, I tried with bash curly brace completion like in the following:

ag --hidden --ignore {.git,plugged} -g ""

But it didn't work, and rightfully so. Because the stuff inside the curly braces, after completion would look like

ag --hidden --ignore .git plugged -g ""

After browsing a little I tried:

ag --hidden --ignore={.git,plugged} -g ""

And it worked. But why using --ignore=PATTERN yield same result as --ignore PATTERN when the documentation (man ag) clearly states the way to be --ignore PATTERN?


Solution

  • This is a known issue with ag's command line parsing vs. its documentation. See:

    1. https://github.com/ggreer/the_silver_searcher/issues/778
    2. https://github.com/ggreer/the_silver_searcher/pull/707

    In this specific case, since ag properly reads the ignore pattern with and without the equal sign, it seems more like an undocumented feature than a short coming.