[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: An xtrace variant

From: Eli Schwartz
Subject: Re: An xtrace variant
Date: Mon, 29 Jun 2020 11:49:17 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0

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.

You DON'T have the facilities in .bashrc for scripts per default. If
your script relies on it, then it shouldn't. If it still does rely on
it, then it should manually source it to ensure it is actually
available, or you should factor out significant code into a shell library.

While you're at it you could make a shell library that looks for $XTRACE
and invokes 'set -x; unset XTRACE', which gets rid of the PITA you're
worried about too, and lets you choose exactly where in the script you
start debugging, so you can also skip preambles/lists of constants.

Eli Schwartz
Arch Linux Bug Wrangler and Trusted User

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]