git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] t6022: Use -eq not = to test output of wc -l

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Nov 16, 2010, 07:12 UTC
Message-ID
<4CE22EC2.7040603@viscovery.net>
In-Reply-To
<7vaalajkiq.fsf@alter.siamese.dyndns.org>
Am 11/15/2010 23:21, schrieb Junio C Hamano:
Show 18 quoted lines
> Brian Gernhardt <brian@gernhardtsoftware.com> writes:
> 
>> When comparing numbers such as "3" to "$(wc -l)", we should check for
>> numerical equality using -eq instead of string equality using = because
>> some implementations of wc output extra whitespace.
>>
>> Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>
>> ---
>>  The alternative would be to use 3 = $(wc -l) (sans quotes), but other parts
>>  of the test used the -eq method.
> 
> ... which looks a tad ugly.
> 
> How about doing something like below after merging Jonathan's fb3340a
> (test-lib: introduce test_line_count to measure files, 2010-10-31) instead?
> 
> -- >8 --
> test_line_count: learn how to read from a pipe
I don't think that any of this (neither Jonathan's nor yours) has any benefit:
- The result is not easier to read.
- Nor are the lines of shell code shorter.
- If something in the pipe requires quoting, you need an extra level of
quotes.
- It doesn't save any messages or fix-ups during review: instead of "do
not quote!" we have to say "use test_line_count!".
Just my opinion.
-- Hannes
Previous: Bert WesargNext: Jonathan Nieder
Message 6 of 9 in “t6022: Use -eq not = to test output of wc -l”
  1. t6022: Use -eq not = to test output of wc -lBrian Gernhardt, Nov 8, 2010
  2. Ævar Arnfjörð BjarmasonNov 8, 2010
  3. Jonathan NiederNov 8, 2010
  4. Junio C HamanoNov 15, 2010
  5. Bert WesargNov 16, 2010
  6. Johannes SixtNov 16, 2010
  7. Jonathan NiederNov 16, 2010
  8. Junio C HamanoNov 16, 2010
  9. Jonathan NiederNov 16, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.