git stderr output can't pipe

前端 未结 3 975
轻奢々
轻奢々 2020-12-09 19:12

I\'m writing a graphical URI handler for git:// links with bash and zenity, and I\'m using a zenity \'text-info\' dialog to show git\'s clone output while it\'s running, usi

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-09 19:46

    For one thing, the output redirection is parsed right-to-left, so

    git clone "$1" "$target" 2>&1 > /tmp/githandler-fifo &
    

    is not equal to

    git clone "$1" "$target" > /tmp/githandler-fifo 2>&1 &
    

    The latter will redirect stderr to stdout, and then stdout (including stderr) to the file. The former will redirect stdout to the file, and then show stderr on stdout.

    As for piping to zenity (which I don't know), I think you may be making things overly complicated with the named pipe. Using strace may shed some light on the inner workings of the processes you're firing up. For the inexperienced, named pipes make things worse compared to normal pipes.

提交回复
热议问题