Server DIY Backup script redirect debug messages to stderr

In "utils.sh" there is a function called "run", with this comment:

"Log then execute the provided command".

This is the last row of the function:

"debug "Running${cmdline}" > /dev/stderr"

 

Please explain me why a debug message should go to the stderr instead of the stdout? (it's a debug message!)

1 answer

0 votes

Hi Ezio, it looks to be a general preference to have debugging messages sent to stderr instead of stdout. For example, from Stackoverflow :

 

Regular output (the actual result of running the program) should go on stdout, things like diagnostic, notice, warning, error, etc, go on stderr.

If there is no "regular output", I would say that it doesn't really matter which one you choose. You could argue that the logging is the only output, so that should go to stdout. Or you could argue that it is still "exceptional information" which should go to stderr.

The backup scripts don't really have regular output, so we 're sending those messages to stderr.
 
Hope this helps!
Ana

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

690 views 5 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you