Question

Running hg branch from a random location without a repository results in the following output:

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

I don't want to see these errors so I tried hg branch 2>/dev/null resulting in the following:

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

Where is this line coming from if not stderr? I figured mercurial may echo these errors to standard output as well, so I tried $ hg branch 2>&1 | awk '{print "test: "$0}' resulting in:

$ 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)!

What I want to do is run hg branch and get either the name of the branch I'm in, or no output at all. Any ideas?

Was it helpful?

Solution

I'm an idiot.

I attempted to add hg branch to my PS1, so I'd know what branch I'm working on while in the terminal. The first error was a remnant of a previous attempt in my .bashrc.

Silly mistake as always :) Thanks anyway guys!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top