[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] How to prevent duplicate echo when using set -x?
From: |
Dan Douglas |
Subject: |
Re: [Help-bash] How to prevent duplicate echo when using set -x? |
Date: |
Fri, 10 Aug 2012 23:14:37 -0500 |
User-agent: |
KMail/4.8.3 (Linux/3.4.6-pf+; KDE/4.8.3; x86_64; ; ) |
On Friday, August 10, 2012 07:19:19 PM adrelanos wrote:
> I want to let debugging with set -x activate, but not show any comments
> twice. Do you know a solution?
#!/bin/bash
set() {
set "$@"
toggleEchoWrap
}
toggleEchoWrap()
if [[ $- == *x* ]]; then
echo() {
<()
}
else
unset -f echo
fi
main() {
# ...
}
toggleEchoWrap
main "$@"
I wouldn't actually do this. Use Bashdb and Bash's many debugging features for
big scripts.
If your code is really huge enough to require documented code you might want
ksh for its self-documenting classes/methods via typeset -h.
In Gentoo we use an awk script to generate eclass manpages, in case you'd like
to roll your own hack.
http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/app-portage/eclass-
manpages/files/eclass-to-manpage.awk
--
Dan Douglas
signature.asc
Description: This is a digitally signed message part.