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

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

From
NSNicolas Sebrecht <nicolas.s.dev@gmx.fr>
Date
Aug 7, 2009, 04:39 UTC
Message-ID
<20090807043929.GJ12924@vidovic>
In-Reply-To
<7GvFnE4br-8WnXmtoea9V1LPY-qshCw6arPr6H40SRG59-b7YcpTsw@cipher.nrlssc.navy.mil>
The 06/08/09, Brandon Casey wrote:
Show 18 quoted lines
> The "former", or Junio's original patch, effectively has this form:
> 
>    {
>       sed "$1"
>    } < "$1"
> 
> Without reading closely enough, I thought it looked like this:
> 
>    {
>       sed
>    } < "$1"
> 
> Since I didn't study the sed statement closely enough, I assumed that it was
> operating on the remaining portion of the patch email that was redirected to
> the block on stdin.  I missed the fact that the file name was supplied to
> it.  My comment was that I found it strange (and maybe unintuitive, or maybe
> it's just me) that "$1" was piped on stdin and it was supplied as an
> argument to sed.

Thinking to this a bit more, I tend to think that your intention to get rid of the "$1" argument of sed is the right thing to do.

It really seems like the argument has precedence to the redirection
  _but_

I couldn't find any reference to this case in POSIX and I guess that the behaviour may differ between implementations of sed. I don't know. Perhaps somebody could tell us if our hesitation is justified (or not)?

Finally and to prevent strange behaviours, I would write
  {
    real l1
    real l2
    real l3
    {
      echo "$l1"
      echo "$l2"
      echo "$l3"
      cat
    } | sed
  } < "$1"
instead of
  {
    real l1
    real l2
    real l3
    sed "$1"
  } < "$1"

because the latter may contain either the content of the whole file (coming from the argument) or the content of the file _whithout_ the first three lines (coming from the redirection '<' amputated by the 'read' statements).

Junio?
-- 
Nicolas Sebrecht
Previous: Brandon CaseyNext: Junio C Hamano
Message 16 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.