From: Junio C Hamano Date: Thu, 16 Jul 2009 02:41:31 GMT Subject: Re: [PATCH v3] Re: git-am: fix maildir support regression: accept email file as patch Message-ID: <7v7hy9bb8k.fsf@alter.siamese.dyndns.org> In-Reply-To: <20090716004952.GB12971@vidovic> Nicolas Sebrecht writes: > I don't see the reason to have the option -v. It's only related to > what's printed to output and doesn't change the exit status which > tell us if an expression has matched. > > This gives: > > grep -E -e '^[A-Za-z]+(-[A-Za-z]+)*:' >/dev/null && > patch_format=mbox That grep says "if you see a single line that matches the pattern, even if all the other lines are garbage, report it as a match". See "something like this" patch in my other message. It filters the entire header to make sure there is no line that does not match (that is what -v is about), and make it report success when there is even a signle line that does not. $ (echo yes; echo no) | grep -v -e yes ; echo $? no 0 $ (echo yes; echo yes) | grep -v -e yes ; echo $? 1 That is why I wrote the "how about this" patch with "||" like this: grep -v -E -e '^[A-Za-z]+(-[A-Za-z]+)*:' >/dev/null || patch_format=mbox If everything is header, grep says "nothing matches", and patch_format is set to mbox.