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

Re: [PATCH v2] Re: mailinfo: allow individual e-mail files as input

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 7, 2009, 05:25 UTC
Message-ID
<7vtz0k5h64.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20090807043929.GJ12924@vidovic>
Nicolas Sebrecht <nicolas.s.dev@gmx.fr> writes:
> It really seems like the argument has precedence to the redirection
> I couldn't find any reference to this case in POSIX and I guess that the
> behaviour may differ between implementations of sed.
> Perhaps somebody could tell us if our hesitation is justified (or not)?

If you give file arguments, standard input is irrelevant to sed. I bet you do:

	$ sed -e something file

all the time, and you rely on the command not to get stuck after reading the file because now it wants to continue reading from its stdin, which is connected to your terminal. Have you ever worried about having to type ^D after every such invocation of sed? I bet you never have ;-)

Also, your _preferred_ alternative
	{ read l1; read l2; read l3;
          ( echo "$l1"; echo "$l2"; echo "$l3"; cat | sed )
	} <"$1"

is not just simply inefficient, but is actively wrong. The "read" can butcher your input. For example, try:

	$ echo "a b " | ( read l1; echo "<$l1>" )
Previous: Nicolas SebrechtNext: Brandon Casey
Message 17 of 24 in “What's in git.git (Aug 2009, #01; Wed, 05)”
  1. Junio C HamanoAug 5, 2009
  2. Brandon CaseyAug 6, 2009
  3. Nicolas SebrechtAug 6, 2009
  4. Nicolas SebrechtAug 6, 2009
  5. 1/3 t4150-am: demonstrate git-am's failure to handle some patch emailsBrandon Casey, Aug 7, 2009
  6. 2/3 mailinfo: allow individual e-mail files as inputBrandon Casey, Aug 7, 2009
  7. 3/3 git-am: print fair error message when format detection failsBrandon Casey, Aug 7, 2009
  8. Jeff KingAug 7, 2009
  9. Brandon CaseyAug 7, 2009
  10. mailinfo: allow individual e-mail files as inputBrandon Casey, Aug 7, 2009
  11. Re: mailinfo: allow individual e-mail files as inputNicolas Sebrecht, Aug 7, 2009
  12. Re: mailinfo: allow individual e-mail files as inputNicolas Sebrecht, Aug 7, 2009
  13. Brandon CaseyAug 7, 2009
  14. Re: mailinfo: allow individual e-mail files as inputNicolas Sebrecht, Aug 7, 2009
  15. Brandon CaseyAug 7, 2009
  16. Re: mailinfo: allow individual e-mail files as inputNicolas Sebrecht, Aug 7, 2009
  17. Junio C HamanoAug 7, 2009
  18. Brandon CaseyAug 7, 2009
  19. 2/3 Re: mailinfo: allow individual e-mail files as inputNicolas Sebrecht, Aug 7, 2009
  20. Brandon CaseyAug 7, 2009
  21. Junio C HamanoAug 7, 2009
  22. Nanako ShiraishiAug 7, 2009
  23. Junio C HamanoAug 7, 2009
  24. Brandon CaseyAug 7, 2009

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.