ag.vim icon indicating copy to clipboard operation
ag.vim copied to clipboard

Check the exit status of `ag` commands

Open losingkeys opened this issue 11 years ago • 2 comments

This could be used for displaying an error message when:

  • stuff isn't found
  • the ag command didn't work (if it's not installed or g:agprg is wrong)

And probably other things?

losingkeys avatar Dec 19 '13 18:12 losingkeys

Also don't open the error/location list when there aren't any matches because of an error (any nonzero exit status?)

losingkeys avatar Dec 22 '13 06:12 losingkeys

It seems like checking v:shell_error would work, but that doesn't seem to be set for :grep. The error message could be parsed, but sometimes (imo) it's confusing. For instance, if you do ag --max-count=garbage test it'll still search for test, but in addition to results it'll display something like:

ERR: Too many matches in ./autoload/ag.vim. Skipping the rest of this file.
ERR: Too many matches in ./doc/ag.txt. Skipping the rest of this file.

At the top of the matches.

Also, ag ----- (invalid option) gives:

ag: unrecognized option `-----'

Usage: ag [FILE-TYPE] [OPTIONS] PATTERN [PATH]

  Recursively search for PATTERN in PATH.
  Like grep or ack, but faster.
...

ag vim dsfajlkfdjsasdj/2/ (invalid path) gives:

ERR: Error stat()ing: dsfajlkfdjsasdj/2
ERR: Error opening directory dsfajlkfdjsasdj/2: No such file or directory

So ERR doesn't always show up, and sometimes you still get results when it does (so it might not be worth it to hide the quickfix window and show the message in those cases.

losingkeys avatar May 21 '14 17:05 losingkeys