implement grep's -q, --quiet, --silent #107

Closed
kch opened this Issue Dec 15, 2009 · 2 comments

3 participants

@kch

Suppresses normal output.

update: I have edited this twice now with conflicting claims. The current post reflects what I'm getting with ack 1.90.

With grep, when you use -q it'll exit with 0 only if there's a match.

That's useful when you're using grep/ack as a test condition for another command.

grep -q … && do_something

Right now, simply directing ack's output to /dev/null seems to work here,

ack … >/dev/null && do_something

So -q would be just nice shorthand.

I also noticed this interesting bit of historical trivia in the man for grep. Make what you will of it.

-s, --no-messages
  Suppress error messages about nonexistent or unreadable files.   Portability
  note:  unlike GNU grep, traditional grep did not conform to POSIX.2, because
  traditional grep lacked a -q option and  its  -s  option  behaved  like  GNU
  grep's -q option.  Shell scripts intended to be portable to traditional grep
  should avoid both -q and -s and should redirect output to /dev/null instead.
@rct
rct commented Jan 7, 2010

I would like to see -s, --no-messages option, not in the name of grep compatibility but in the name of less typing. Is that what this is about? I think this should probably be a separate issue from the question of a grep -q mode.

@hoelzro
Collaborator

ack isn't meant to be interface compatible with grep; that being said, the -s option was added to ack2. If you would like to continue discussing this feature, please open it on the ack2 issues queue.

@hoelzro hoelzro closed this Aug 28, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment