From: Eric Sunshine Date: Sun, 27 Mar 2016 17:08:54 GMT Subject: Re: [PATCH v10 2/3] t7507-commit-verbose: store output of grep in a file Message-ID: In-Reply-To: [forwarding this to the list, as well, since I again didn't notice when replying that Pranit had accidentally dropped the mailing list as a recipient] On Sun, Mar 27, 2016 at 12:59 PM, Eric Sunshine wrote: > On Sun, Mar 27, 2016 at 5:05 AM, Pranit Bauva wrote: >> On Sun, Mar 27, 2016 at 12:40 PM, Eric Sunshine wrote: >>> However, even if you take the approach of making 'check-for-diff' >>> succeed unconditionally and always count diffs, the current >>> implementation is still overly complicated. It would be much simpler >>> to let 'check-for-diff' always create the output file, and then use >>> "test_line_count = 0 out" when expecting no diffs than to sometimes >>> create the output file and sometimes not. The shell '>' operator will >>> truncate the file to zero size even before grep is invoked, so you >>> don't need to worry that results from an earlier test will pollute >>> 'out' for a subsequent test, even if grep finds no matches. Thus, >>> 'check-for-diff' collapses to this tiny implementation: >>> >>> grep '^diff --git' "$1" >out >>> exit 0 >>> >>> Or, if you want to be terse: >>> >>> grep '^diff --git' "$1" || exit 0 >out >> >> I tried using both of this and it gives an error > > These worked fine for me when I rewrote the test script before making > the suggestion. You'll need to provide more information if you want to > get to the bottom of the problem you experienced (for instance, show > the exact code you used and the actual error message).