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

Re: [BUG?] "git submodule foreach" when command is ssh

From
Jeff King <peff@peff.net>
Date
Jan 5, 2011, 23:03 UTC
Message-ID
<20110105230334.GB9774@sigill.intra.peff.net>
In-Reply-To
<AANLkTini=GaGSHDX4e1jhPVxKaSayUJoWa=w4u4Rz-+5@mail.gmail.com>
On Thu, Jan 06, 2011 at 11:50:58AM +1300, Chris Packham wrote:
Show 10 quoted lines
> Actually this might be a ssh/bash bug (feature?). There is different
> behaviour between
> 
>   find . -maxdepth 1 -type d -a ! -name '\.*' | while read; do echo
> $REPLY && ssh localhost ls /; done
> 
> and
> 
>   find . -maxdepth 1 -type d -a ! -name '\.*' | while read; do echo
> $REPLY && ls /; done

Ssh will opportunistically eat data on stdin to send to the other side, even though the command on the other side ("ls" in this case) will never read it. Because of course ssh has no way of knowing that, and is trying to be an interactive terminal. So it ends up eating some random amount of the data you expected to go to the "read" call.

You can use the "-n" option to suppress it. For example:
  $ (echo foo; echo bar) |
    while read line; do
      echo local $line
      ssh host "echo remote $line"
    done
produces:
  local foo
  remote foo
but:
  $ (echo foo; echo bar) |
    while read line; do
      echo local $line
      ssh -n host "echo remote $line"
    done
produces:
  local foo
  remote foo
  local bar
  remote bar
which is what you want.
-Peff
Previous: Chris PackhamNext: Chris Packham
Message 3 of 5 in “[BUG?] "git submodule foreach" when command is ssh”
  1. Chris PackhamJan 5, 2011
  2. Chris PackhamJan 5, 2011
  3. Jeff KingJan 5, 2011
  4. Chris PackhamJan 5, 2011
  5. Seth RobertsonJan 5, 2011

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.