Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #16492
| From | Chet Ramey <chet.ramey@case.edu> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Re: An xtrace variant |
| Date | 2020-06-29 11:37 -0400 |
| Organization | ITS, Case Western Reserve University |
| Message-ID | <mailman.659.1593445082.2574.bug-bash@gnu.org> (permalink) |
| References | <878sg61w0w.fsf@hobgoblin.ariadne.com> <7af7e0c5-97f4-b8de-1e03-06c08cd722c9@case.edu> |
On 6/28/20 9:49 PM, Dale R. Worley wrote: > Eli Schwartz <eschwartz@archlinux.org> writes: >> Why not just run bash -x script-name without the bash -l option and >> without $BASH_ENV set? >> >> The first is implicitly true based on your stated command line. The >> second doesn't seem like a high bar to set, and it's not exactly default >> behavior... if you really do need $BASH_ENV can't you do the set -x at >> the end of that file? > > That's a good point, and I admit I've never studied out all of the logic > of Bash init files; I assumed that it executed ~/.bashrc as a matter of > course. > > So as long as I don't need the facilities in .bashrc for the script, > then "BASH_ENV= bash ..." suffices. > > In regard to "can't you do the set -x at the end of that file", (1) it's > inelegant and a PITA, and (2) it sauses sub-scripts to generate > debugging output. If you're in the habit of using BASH_ENV regularly, add something like [[ -n "$XTRACE" ]] && set -x to the end of $BASH_ENV, which you only have to do once and is normally a no-op, and then run your scripts as `XTRACE=y bash scriptname'. That's no more inelegant than adding an option to bash. If you don't want it to run more than once, unset XTRACE after `set -x'. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/
Back to gnu.bash.bug | Previous | Next | Find similar
Re: An xtrace variant Chet Ramey <chet.ramey@case.edu> - 2020-06-29 11:37 -0400
csiph-web