Re: [PATCH] Fix use of wc in t0000-basic
- From
Sean <seanlkml@sympatico.ca>
- Date
- May 21, 2005, 01:08 UTC
- Message-ID
- <4600.10.10.10.24.1116637737.squirrel@linux1>
- In-Reply-To
- <Pine.LNX.4.21.0505202045580.30848-100000@iabervon.org>
On Fri, May 20, 2005 8:49 pm, Daniel Barkalow said:
Show 20 quoted lines
> The version of wc I have (GNU textutils-2.1) puts spaces at the beginning > of lines. This patch should work for any version of wc. > > Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> > Acked-by: Junio C Hamano <junkio@cox.net> > Index: t/t0000-basic.sh > =================================================================== > --- 58741c69570705801db4b785681790d636475695/t/t0000-basic.sh > (mode:100755 sha1:9a557129d98b499bcd601903d6646de29ba4bfc5) > +++ uncommitted/t/t0000-basic.sh (mode:100755) > @@ -32,7 +32,7 @@ > find .git/objects -type d -print >full-of-directories > test_expect_success \ > '.git/objects should have 256 subdirectories.' \ > - 'test "$(wc -l full-of-directories | sed -e "s/ .*//")" = 257' > + 'test $(cat full-of-directories | wc -l) = 257' > > ################################################################ > # Basics of the basics >
You can't do "wc -l filename" because some versionso of "wc" then include the filename in their output and confuse things. That was the reason to use "cat" in the first place. If you're going to use sed, just do away with wc altogether:
sed -ne '$=' full-of-directories
And that should work everywhere to get a line count.
Cheers, Sean