0
For some reason this assignment: OUT=$(git describe HEAD)
prints to the stdout (for example): fatal: No names found, cannot describe anything.
Is this a normal behavior? Why doesn't this happen with other commands?
0
For some reason this assignment: OUT=$(git describe HEAD)
prints to the stdout (for example): fatal: No names found, cannot describe anything.
Is this a normal behavior? Why doesn't this happen with other commands?
1
That's actually stderr
output, not stdout
. When running a command from an interactive terminal, both stdout
and stderr
are set to go to the terminal.
If you wanted the stderr
output in your variable (which you probably don't, but anyway), redirect it to stdout
like this:
OUT=$(git describe HEAD 2>&1)
Or if you didn't want the person running your script to see that stderr
output, throw it away like this:
OUT=$(git describe HEAD 2>/dev/null)