Thread (5 messages) flat view 5 messages, 3 authors, 2016-06-15

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

From: Jeff King <hidden>
Date: 2016-06-15 22:50:20

On Thu, Jan 06, 2011 at 11:50:58AM +1300, Chris Packham wrote:
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help