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

Re: [PATCH] t3920: don't ignore errors of more than one command with `|| true`

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 23, 2022, 00:55 UTC
Message-ID
<xmqq1qpupk0k.fsf@gitster.g>
In-Reply-To
<221123.86ilj6a8ux.gmgdl@evledraar.gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 23 quoted lines
> We have that "sed -n -e" in somewhat wide use:
>
> 	$ git grep 'sed (-n -e|-ne).*/p.*&&' | wc -l
> 	54
>
> The only existing occurance of this "grep but ignore the exit code" I
> could find was:
>
> 	t/t9001-send-email.sh:  { grep '^X-Mailer:' out || :; } >mailer &&
>
> For which we can also:
>
> 	-       { grep '^X-Mailer:' out || :; } >mailer &&
> 	+       sed -ne '/^X-Mailer:/p' <out >mailer &&
>
> And which I'd think would be great to have in a re-roll, i.e. "here's
> these two cases where a grep-but-dont-care-about-the-exit-code could be
> replaced by sed -ne".
>
> But if re-testing this is tedious etc. I don't mind if it goes in as-is,
> but then I'd think we could safely emulate the t9001-send-email.sh
> pattern of using ":" instead of "true"; we don't need to invoke another
> process just to ignore the exit code.

Let's leave all of the above (mostly good ideas) for "after the dust settles" clean-up.

If sed is much slower than grep (for such a small string use case, start-up cost of a process would dwarf everybody else), "grep || :" might be justifiable, but other than that I do not think of a good reason why we might favor "grep || :" offhand over "sed -ne //p".

Previous: Ævar Arnfjörð BjarmasonNext: René Scharfe
Message 8 of 25 in “t3920: don't ignore errors of more than one command with `|| true`”
  1. t3920: don't ignore errors of more than one command with `|| true`Johannes Sixt, Nov 21, 2022
  2. René ScharfeNov 21, 2022
  3. Junio C HamanoNov 22, 2022
  4. Philippe BlainNov 22, 2022
  5. Ævar Arnfjörð BjarmasonNov 22, 2022
  6. Johannes SixtNov 22, 2022
  7. Ævar Arnfjörð BjarmasonNov 22, 2022
  8. Junio C HamanoNov 23, 2022
  9. 2/1 t3920: support CR-eating grepRené Scharfe, Dec 2, 2022
  10. Philippe BlainDec 2, 2022
  11. René ScharfeDec 3, 2022
  12. Eric SunshineDec 2, 2022
  13. René ScharfeDec 3, 2022
  14. Junio C HamanoDec 5, 2022
  15. René ScharfeDec 5, 2022
  16. Junio C HamanoDec 5, 2022
  17. René ScharfeDec 5, 2022
  18. 3/1 t3920: simplify redirection of loop outputRené Scharfe, Dec 2, 2022
  19. 4/1 t3920: replace two cats with a teeRené Scharfe, Dec 2, 2022
  20. Eric SunshineDec 3, 2022
  21. René ScharfeDec 3, 2022
  22. Ævar Arnfjörð BjarmasonDec 3, 2022
  23. René ScharfeDec 3, 2022
  24. Ævar Arnfjörð BjarmasonDec 4, 2022
  25. Eric SunshineDec 4, 2022

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.