Suppress dispensable 'set -x' debug output unless called with '--debugscripts x' #2024
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Intent:
Improve readability of the ReaR log file by suppressing
particular
set -x
debug output that is usually of no interestso that it gets easier for our users and for us to analyze an issue
by inspecting the log file when rear was called in debugscripts mode.
Type: Enhancement
Impact: Low
How was this pull request tested?
By me on my openSUSE Leap 15.0 system
Brief description of the changes in this pull request:
I think a noticeable part of the
set -x
debugscripts output(that part is about 25% for my initial test, see below)
is usually of no interest and therefore dispensable by default.
This pull request is a proposal how we could suppress dispensable
debug output by default (in particular when rear is called with '-D')
unless rear is called with '--debugscripts x' where the full debugscripts
output is still there as it was before.
The basic idea is to suppress uninteresting output that goes to stderr
(in particular where
set -x
debugscripts output is usually of no interest)by default via setting in usr/sbin/rear (i.e. this is no user config variable)
and by using where applicable in the scripts code of the form
provided none of the commands outputs intentionally to stderr
(i.e. there is only
set -x
debugscripts output for the commands)unless rear is called with '--debugscripts x' where in usr/sbin/rear
is set which results in the above code
and /dev/stderr is fd2 which is redirected to append to RUNTIME_LOGFILE
so that 2>>/dev/stderr does not change things and fd2 output is still
appended to RUNTIME_LOGFILE.
What happens in compacted form is with
2>>/dev/null
versus with
2>>/dev/stderr
FYI how things go wrong when
2>/dev/stderr
is used:because
2>/file
truncates the file to zero size.I tested
rear -D mkrescue
versusrear --debugscripts x mkrescue
and got 53807
set -x
lines in the log file with suppressed dispensable debug outputversus 68862
set -x
lines in the log file with full debugscripts output as it was before.My initial suppressed dispensable debug output is primarily
the
set -x
debugscripts output for some outupt functions andthe
set -x
debugscripts output for IsInArray() and RmInArray().@rear/contributors
if you agree to the general idea behind and
if my implementation is not somehow broken by design
we could likely find more functions (or other code parts)
where the full
set -x
debug output is usually of no interest.