Dear helpful git-using lazyweb,
Thanks for the answers to the previous question. I have another question. I see this:
$ git fetch -q >/dev/null From git://camel/perl 249829c..ba2d061 blead -> origin/blead
Is there any way to run git fetch
such that it produces no summary output to stderr, unless there is an error. I don't want to hack up a parser for "expected noise", and I don't want a cron job mailing me every time if "nothing is wrong". It's not clear from the man page that this is possible, and the "obvious" above doesn't work. Heck, even forcibly ensuring that nothing is a tty still doesn't work:
$ git fetch -q 2>&1 >/dev/null origin/blead
(That's on a different machine. I don't have a test remote repository where I generate commits to try things out. That feels futile.)
Re:Broken redirect
ilmari on 2009-08-11T17:33:00
Bah, I misread, I thought you wanted STDERR to go to/dev/null, not to cat's STDIN. Sorry.
Uh... wouldn't "2>&1 >/dev/null" just put what's going to stderr to stdout and what's going to stdout to nothing, as opposed to both stderr and stdout to nothing?
I think you need "2>/dev/null" for what you want.
Re:Funny redirecting?
nicholas on 2009-08-11T17:44:41
Uh... wouldn't "2>&1 >/dev/null" just put what's going to stderr to stdout and what's going to stdout to nothing, as opposed to both stderr and stdout to nothing?
Yes.
I think you need "2>/dev/null" for what you want.
No.
:-) I'm relying on the order of parsing of pipes and redirection.
git fetch -q 2>&1 >/dev/null </dev/null | cat
is parsed as run this:git fetch -q 2>&1 >/dev/null </dev/null
piped to that:
cat
Then,
git fetch -q 2>&1 >/dev/null </dev/null
is parsed as
- Redirect stderr to a dup of stdout (which happens to be a pipe, not a tty)
- Redirect stdout to
/dev/null
- Redirect stdin from
/dev/null
At which point no file descriptor that
git
can see is a tty (in case it behaves differently, à lagit log
), but stderr is still open so I can follow advice from Klortho 11906, 11914, 11919, 11920, and especially 11922:-) At which point I want the command to get the hint and be silent, dammit, if nothing is wrong, but it's simply not taking the hint.
:-( Re:Funny redirecting?
DiamondInTheRough on 2009-08-11T19:02:32
Sorry. Misunderstood what you meant, then. Better answers are below.
-qq
, though I'm not sure exactly where that's supposed to be documented.
This just works as expected with single -q on git 1.6.4 (and doesn't on 1.5.2.1).
Time to upgrade...