Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Journal of nicholas (3034)

Tuesday August 11, 2009
11:11 AM

Dear helpful git-using lazyweb

[ #39446 ]

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 </dev/null | cat
From nicholas@perl5.git.perl.org:/gitroot/perl
   249829c..ba2d061  blead      -> 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.)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Your redirect is wrong, you need to redirect STDERR after STDOUT, since it does dup2(2, 1) which is still your terminal if you do it before.

    $ (echo foo >&2) 2>&1 >/dev/null
    foo
    $ (echo foo >&2)  >/dev/null 2>&1
    $
    • 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.

    --
    The new Strawberry Perl for Windows has been released! Check http://strawberryperl.com for it.
    • 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

      • Sorry. Misunderstood what you meant, then. Better answers are below.
        --
        The new Strawberry Perl for Windows has been released! Check http://strawberryperl.com for it.
  • -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... :-)