Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #16493

Re: An xtrace variant

Path csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From Eli Schwartz <eschwartz@archlinux.org>
Newsgroups gnu.bash.bug
Subject Re: An xtrace variant
Date Mon, 29 Jun 2020 11:49:17 -0400
Lines 84
Approved bug-bash@gnu.org
Message-ID <mailman.661.1593445772.2574.bug-bash@gnu.org> (permalink)
References <878sg61w0w.fsf@hobgoblin.ariadne.com> <e0318cb2-16a2-c0b9-66be-96326c5e8c10@archlinux.org>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="XmcG7Ph2EQ0jO0X02ALJx8oahCCeBRiAi"
X-Trace usenet.stanford.edu 1593445772 17547 209.51.188.17 (29 Jun 2020 15:49:32 GMT)
X-Complaints-To action@cs.stanford.edu
Cc bug-bash@gnu.org
To "Dale R. Worley" <worley@alum.mit.edu>
Envelope-to bug-bash@gnu.org
X-Spam-BL-Results
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=orion; t=1593445762; bh=nTDi5Sw4uOX5bFMgluFwMi+wvOH1GTXt5o+vXxIjJbw=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=meOMeEHSpqu5R5/p4o6Dnc6dn2FCDBzRG4AFiA4QgodfF3ZDHzEC+Z3AldBG4omwp 1L4pyQeVIqADIEoe7qSiH8nmkX2qYDsRFl4KMvryd4kDR4UAOCTjfihXb7y2FVI57y vHydBoDTbkLuoHbwn6KWt++Se2eKkSHA9JHlv6NeJZWvqaJtMy54GEDA+U3P336AD5 ALZnKq3JdA2XQ0vCgohIhaTvjGo5Jqscmn5WY1oJWyDdRsz1Zh+rKh+f+kRo8WqBEe ECjcl5SF2Cxa4Vldjc0tJp2zTsO5utMAxgfZ+Yowqlr3IUjnSLzVaYucM1Oz93fzRR mSfMptaYmDNogJ3rPqcpfa9XePh0UqPDsTbRnoWiDnyaHFI3FumUNDXcjo2Hd8Ky+E gPVOTpdc/5IARoNYuAz4SG+qWrkHEQoD5lKPgY/LOtWCCVP2jGPcz3grHm7rfwK6DE Qo+6Qo7iIj4WNF7IVmB2DSxoUWqEMjz2yXecanJ6+JTNmKu+kJlrmfeuYB4x1nAQnZ YaVMhqPwWocrE1ccicVsyCVEWvj+r5s7TTz+liBgazJ6k8EYvTuwcZhQau/6dOS20L r5Yr7LUwUkwYY9vDAZlkbOz7eRaP5yVDbEUTmPZa7oLIhZvFiz8pmk5Gl+WcdN5MPl idCo+hcFHm+KSWIOAjIyU/M4=
X-Clacks-Overhead GNU Terry Pratchett
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0
In-Reply-To <878sg61w0w.fsf@hobgoblin.ariadne.com>
Received-SPF pass client-ip=88.198.91.70; envelope-from=eschwartz@archlinux.org; helo=orion.archlinux.org
X-detected-operating-system by eggs.gnu.org: First seen = 2020/06/29 11:49:23
X-ACL-Warn Detected OS = Linux 2.2.x-3.x [generic] [fuzzy]
X-Spam_score_int -53
X-Spam_score -5.4
X-Spam_bar -----
X-Spam_report (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN
X-Spam_action no action
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <e0318cb2-16a2-c0b9-66be-96326c5e8c10@archlinux.org>
X-Mailman-Original-References <878sg61w0w.fsf@hobgoblin.ariadne.com>
Xref csiph.com gnu.bash.bug:16493

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

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

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: An xtrace variant Eli Schwartz <eschwartz@archlinux.org> - 2020-06-29 11:49 -0400

csiph-web