#688 Issue closed
: In DEBUGSCRIPTS mode print shell input lines as they are read?¶
Labels: enhancement
, documentation
, fixed / solved / done
jsmeix opened issue at 2015-11-11 12:11:¶
Currently when in DEBUGSCRIPTS mode only "set -x" is done.
Personally I prefer "set -vx" when debugging bash scripts because
'-v' prints the script source code lines (in chunks as read by bash) and
afterwards '-x' prints the commands and their arguments as they are
executed.
For me this makes debugging issuse very much faster because I see first the original source code lines and then what commands and arguments the bash eveluation results which helps me very much to understand what is actually happening.
Hereby I request that in DEBUGSCRIPTS mode "set -vx" is done.
I propose the following in usr/share/rear/lib/framework-functions.sh
(plus some explanatory comments):
function Source() { ... # in DEBUGSCRIPTS mode print shell input lines as they are read # and print commands and their arguments as they are executed: test "$DEBUGSCRIPTS" && set -vx # the actual work (source the source file): Debug "Begin sourcing '$source_file'" . "$source_file" Debug "End sourcing '$source_file'" # undo DEBUGSCRIPTS mode settings: test "$DEBUGSCRIPTS" && set +vx
If you like it, I make a pull request.
schlomo commented at 2015-11-11 12:59:¶
:-) I know the -v
feature and it always confused me to see almost the
same content twice... In my Bash debugging needs so far -v
played a
seldom and minor role. I sometimes add : $VAR
in the code to see the
content of a variable in -x
mode.
Question: Is it a matter of taste? Should we allow configuration for this?
jsmeix commented at 2015-11-11 13:11:¶
@schlomo
just propose what rear command line parameter you like
for "set -v" and I will implement it.
Perhaps a command line parameter '-C' for "Code"
or something like that?
jsmeix commented at 2015-11-11 13:14:¶
Or perhaps even better add support for a value for the '-D'
parameter where the value is by default 'x' like:
rear -D
results "set -x" and
rear -D vx
results "set -vx"
and
rear -D v
results "set -v".
This way - for debugging by experts - even
rear -D xvue
could be set.
schlomo commented at 2015-11-11 13:58:¶
I think I prefer -D and -DD, interpreting -v as an additional
verbosity
layer on top of -x.
What do you think?
On 11 November 2015 at 14:14, Johannes Meixner
notifications@github.com
wrote:
Or perhaps even better add support for a value for the '-D'
parameter where the value is by default 'x' like:rear -D
results "set -x" and
rear -D vx
results "set -vx"
and
rear -D v
results "set -v".
—
Reply to this email directly or view it on GitHub
https://github.com/rear/rear/issues/688#issuecomment-155783148.
gdha commented at 2015-11-11 14:34:¶
We already have verbose (-v). Why don't use this as a trigger for set
-x$v ? Keep it simple no?
Gratien
Verstuurd vanaf mijn iPhone
Op 11 nov. 2015 om 14:58 heeft Schlomo Schapiro notifications@github.com het volgende geschreven:
I think I prefer -D and -DD, interpreting -v as an additional verbosity
layer on top of -x.What do you think?
On 11 November 2015 at 14:14, Johannes Meixner notifications@github.com
wrote:Or perhaps even better add support for a value for the '-D'
parameter where the value is by default 'x' like:rear -D
results "set -x" and
rear -D vx
results "set -vx"
and
rear -D v
results "set -v".
—
Reply to this email directly or view it on GitHub
https://github.com/rear/rear/issues/688#issuecomment-155783148.—
Reply to this email directly or view it on GitHub.
schlomo commented at 2015-11-11 16:46:¶
@gdha brilliant idea - thanks a lot for seeing the simple things!
On 11 November 2015 at 15:34, gdha notifications@github.com wrote:
We already have verbose (-v). Why don't use this as a trigger for set -x$v
? Keep it simple no?
GratienVerstuurd vanaf mijn iPhone
Op 11 nov. 2015 om 14:58 heeft Schlomo Schapiro <
notifications@github.com> het volgende geschreven:I think I prefer -D and -DD, interpreting -v as an additional verbosity
layer on top of -x.What do you think?
On 11 November 2015 at 14:14, Johannes Meixner <notifications@github.com
wrote:
Or perhaps even better add support for a value for the '-D'
parameter where the value is by default 'x' like:rear -D
results "set -x" and
rear -D vx
results "set -vx"
and
rear -D v
results "set -v".
—
Reply to this email directly or view it on GitHub
https://github.com/rear/rear/issues/688#issuecomment-155783148.—
Reply to this email directly or view it on GitHub.—
Reply to this email directly or view it on GitHub
https://github.com/rear/rear/issues/688#issuecomment-155798687.
jsmeix commented at 2015-11-12 15:35:¶
Only a note FYI:
For now I cannot work on it because a customer printing issue
appeared.
Using '-v' plus '-D' to get "set -vx" is o.k. for me
but it is not really KISS as I understand what KISS means.
Using '-v' plus '-D' to get "set -vx" is RFC 1925 (5)
from my point of view.
And the result is a backward incompatible change
because before '-v' and '-D' were separated things.
Personally I prefer a variant of KISS:
KSIS: Keep Separated Issues Separated.
But I do not want to make a longer discussion
because of this relatively small issue.
I will implement using '-v' plus '-D' to get "set -vx".
Probably I will also implement that '-D' can have an
optional value because I like to be able to "set -xue"
via '-D xue' for my own personal needs...
pavoldomin commented at 2015-11-12 19:46:¶
Indeed, it's not the best thing if the cmdline options behavior change: e.g. we could expect much bigger logfile on systems where 'rear -v -D' is scheduled (potentially affecting a filesystem utilization).
jsmeix commented at 2015-11-13 14:48:¶
I made a first tentative and currentyl untested implementation
by using a separeated long option --debugscripts that
requires an argument where the argument contains
the flags to be 'set' so thet e.g. '--debugscripts=xv'
results 'set -xv'.
I need to play around with it how it works.
If you like to have a look see
https://github.com/jsmeix/rear/tree/add_optional_value_to_specify_D_command_line_option_settings
jsmeix commented at 2015-11-18 15:33:¶
It happened while working on this issue that I did much more than I actually intended which results the big pull request https://github.com/rear/rear/pull/699
jsmeix commented at 2015-11-18 16:16:¶
Regarding make rear working with ''set -ue -o pipefail"
I created
https://github.com/rear/rear/issues/700
jsmeix commented at 2015-11-20 08:58:¶
This issue is fixed by https://github.com/rear/rear/pull/699 via a new debugscripts option which is fully backward compatible because the behaviour of the other options does not change.
Now one can use e.g.
rear --debugscripts xv mkbackup
or even things like
rear --debugscripts 'xvue +h -o pipefail' help
jsmeix commented at 2015-11-20 13:51:¶
I need to update the man page as well, cf. https://github.com/rear/rear/issues/700#issuecomment-158338328
jsmeix commented at 2015-12-02 09:02:¶
With the added documentation for the new debugscripts option in https://github.com/rear/rear/issues/715 this issue is fixed.
[Export of Github issue for rear/rear.]