From: Jeff King <peff@peff.net>
To: Chris Packham <judge.packham@gmail.com>
Cc: GIT <git@vger.kernel.org>
Subject: Re: [BUG?] "git submodule foreach" when command is ssh
Date: Wed, 5 Jan 2011 18:03:35 -0500 [thread overview]
Message-ID: <20110105230334.GB9774@sigill.intra.peff.net> (raw)
In-Reply-To: <AANLkTini=GaGSHDX4e1jhPVxKaSayUJoWa=w4u4Rz-+5@mail.gmail.com>
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
next prev parent reply other threads:[~2011-01-05 23:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-05 22:32 [BUG?] "git submodule foreach" when command is ssh Chris Packham
2011-01-05 22:50 ` Chris Packham
2011-01-05 23:03 ` Jeff King [this message]
2011-01-05 23:22 ` Chris Packham
2011-01-05 23:02 ` Seth Robertson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110105230334.GB9774@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=judge.packham@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).