From: Mike Hommey Date: Fri, 16 Nov 2007 16:59:44 GMT Subject: Re: [PATCH v2] Fix git-tag test breakage caused by broken sed on Leopard Message-ID: <20071116165944.GB29272@glandium.org> In-Reply-To: <03D3DFCD-B5F7-47CF-AFD2-F1408BB11AB3@wincent.com> On Fri, Nov 16, 2007 at 02:48:09PM +0100, Wincent Colaiuta wrote: > El 16/11/2007, a las 14:45, Wincent Colaiuta escribió: > > > El 16/11/2007, a las 6:14, Junio C Hamano escribió: > > > >> Wincent Colaiuta writes: > >> > >>> diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh > >>> index 096fe33..b54c2e0 100755 > >>> --- a/t/t7004-tag.sh > >>> +++ b/t/t7004-tag.sh > >>> @@ -1007,7 +1007,7 @@ test_expect_failure \ > >>> test_expect_success \ > >>> 'message in editor has initial comment' ' > >>> GIT_EDITOR=cat git tag -a initial-comment > actual || true && > >>> - test $(sed -n "/^\(#\|\$\)/p" actual | wc -l) -gt 0 > >>> + test $(grep -e "^#" -e "^\$" actual | wc -l ) -gt 0 > >>> ' > >> > >> Heh, doesn't grep exit with zero only when it found some lines > >> that match the pattern already? What's that "wc -l" for? > > > > > > I was just trying to make the minimal change (swapping grep for > > sed), but if you want a shorter version then we don't even need the > > "test"; it could just be: > > > > - test $(sed -n "/^\(#\|\$\)/p" actual | wc -l) -gt 0 > > + grep -e "^#" -e "^\$" actual > > Although I don't know if we should be testing for empty lines there > because an 0-byte empty "actual" file would spuriously pass the test. > Perhaps this would be better: > > - test $(sed -n "/^\(#\|\$\)/p" actual | wc -l) -gt 0 > + grep -e "^#" actual Matching both would as in your previous pseudo patch wouldn't catch empty file. On the other hand, both my initial bloated version and yours won't catch a file that doesn't contain the comment. grep -e "^$" actual && grep -e "^#" actual would actually be a better test. Mike