Repository navigation
cronic: do not trace cronic's own command -- ... line when the caller's xtrace is on - #143
Merged
Merged
Conversation
When the caller exports SHELLOPTS, the command inherited cronic's own -e and -u, so a bash script that reads an unset variable (such as texi2dvi) failed. Running the command in a subshell also keeps the exit and exec builtins from ending cronic before it reports.
When the caller exports SHELLOPTS with xtrace or verbose, cronic traced or echoed itself to stderr, so cron sent email on every run. Also keep cronic's setup of the command out of the command's trace output.
…ions # Conflicts: # cronic # tests/cronic-test/cronic-test.sh
…for source and eval
… tests Save the caller's SHELLOPTS rather than a hand-maintained list of option letters, so that every set -o option is restored for the command. Document that verbose and BASH_ENV can still make cronic write to stderr. In the tests, unset PS4, skip trace-section checks when bash lacks BASH_XTRACEFD, and share the PASS/FAIL reporting.
# Conflicts: # cronic
# Conflicts: # cronic # tests/cronic-test/cronic-test.sh
…er's xtrace is on
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 38 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…trace level Swap the trace descriptor only when the caller's xtrace is on and bash is 4.1 or later; run the command directly otherwise. Put the restoring redirection in a function rather than an eval, so that a builtin's trace is not nested an extra level. Test a builtin under xtrace, and check every xtrace case for cronic's own trace. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…he command; tests: generate every SHELLOPTS wrapper with one function, which unsets BASH_ENV
# Conflicts: # cronic # tests/cronic-test/cronic-test.sh
…e comment; tests: run the verbose test through `check`
… same-shell re-exec, reuse BASH_XTRACEFD probe, clarify first-command comment
…e-scripts into cronic-no-command-trace # Conflicts: # cronic # tests/cronic-test/cronic-test.sh
…c-no-command-trace # Conflicts: # cronic # tests/cronic-test/cronic-test.sh
…he traced path as bash does, clarify help text, show diffs on test failure
…, clarify BASH_ENV help text, inline compare_streams, regroup header comments
…nts, drop the SHELLOPTS re-exec and two helper scripts from the tests
…c-no-command-trace # Conflicts: # cronic # tests/cronic-test/cronic-test.sh
…nto cronic-no-command-trace # Conflicts: # cronic # tests/cronic-test/cronic-test.sh
…an running the command in a function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When the caller's xtrace is on (
bash -x cronic ..., or xtrace in an exported SHELLOPTS), the report's TRACE OUTPUT contained+ command -- CMD, which is cronic's line, not the command's.Now, with bash 4.1 or later, cronic removes the first line of the trace file when the caller's xtrace is on. That line is always the trace of the
command -- ...line, because thesetcommand before it is not traced. If PS4 contains a newline, then only the first line of that trace is removed;cronic --helpdocuments that limitation.Bash before 4.1 (no BASH_XTRACEFD) is unchanged.
Tests:
bash -x cronic) no longer contain thecommand --line, so those tests no longer need to compute its expected trace.eval) that sets an EXIT trap.The PR also separates paragraphs in long comments with
#-only lines.