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 Aug 21, 2018 in Bitbucket

Branch Management with Bitbucket

As a project manager, I have discovered that different developers want to bring their previous branching method with them when they join the team. Some developers are used to performing individual wo...

2,354 views 9 12
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