为什么这个mercurial错误不在stderr?

时间:2014-03-17 13:39:29

标签: bash mercurial

从没有存储库的随机位置运行hg branch会产生以下输出:

$ hg branch
abort: no repository found in '/home/abe' (.hg not found)!
abort: no repository found in '/home/abe' (.hg not found)!

我不希望看到这些错误,所以我尝试了hg branch 2>/dev/null,结果如下:

$ hg branch 2>/dev/null
abort: no repository found in '/home/abe' (.hg not found)!

如果不是stderr,这条线来自哪里? 我认为mercurial也可以将这些错误反映到标准输出中,所以我尝试$ hg branch 2>&1 | awk '{print "test: "$0}'导致:

$ hg branch 2>&1 | awk '{print "test: "$0}'
test: abort: no repository found in '/home/abe' (.hg not found)!
abort: no repository found in '/home/abe' (.hg not found)!

我想要做的是运行hg branch并获取我所在的分支的名称,或者根本不输出。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

我是个白痴。

我试图将hg branch添加到我的PS1中,所以我知道在终端中我正在处理什么分支。 第一个错误是我的.bashrc中先前尝试的残余。

愚蠢的错误一如既往:)非常感谢你们!