>if (( debug ))
>then
> _debug()
> {
> "$@"
> # I do question whether this is a viable construct, versus
> # eval "$@"
> }
>else
> _debug()
> {
> :
> }
>fi
>
>2. The other thing is that instead of
>
>#!/bin/bash
>debug=true
>
>at the beginning
On Thu, Aug 11, 2011 at 12:38:17PM -0800, Roger wrote:
> OK. Now I see the collapsing, and it seems more like a hidden collapse rather
> then an immediately apparent collapse from an initial stance after
> reading/tracing. When tracing this function, I was thinking the function
> would be read eac
> On Thu, Aug 11, 2011 at 08:13:27AM -0400, Greg Wooledge wrote:
>On Thu, Aug 11, 2011 at 12:23:00AM -0700, pjodrr wrote:
>> they call it "collapsing functions":
>> http://wiki.bash-hackers.org/howto/collapsing_functions
>
>"The first time you run chatter(), the function redefines itself based on t
Am Donnerstag, 11. August 2011 12:40:24 UTC+2 schrieb Roger:
> Just a quick response here, "ifdef style" is C code not compiled into the
> compiled program if it is not defined or chosen to be enabled. This in turn,
> prevents the CPU from wasting cycles testing if/then statements, etc...
yes, I
Am Donnerstag, 11. August 2011 14:13:27 UTC+2 schrieb Greg Wooledge:
> The problem with this is that you can't switch to the other function
> later.
this is intended. The idea is to call a script with a debug
or no-debug option. So for the runtime of the script the
debug() function does not chan
On Thu, Aug 11, 2011 at 12:23:00AM -0700, pjodrr wrote:
> they call it "collapsing functions":
> http://wiki.bash-hackers.org/howto/collapsing_functions
"The first time you run chatter(), the function redefines itself based on the
value of verbose. Thereafter chatter doesn't check $verbose anymore
> On Thu, Aug 11, 2011 at 12:23:00AM -0700, pjodrr wrote:
>Hello,
>
>Am Montag, 8. August 2011 19:20:25 UTC+2 schrieb Steven W. Orr:
>>
>> if (( debug ))
>> then
>> _debug()
>> {
>> "$@"
>> # I do question whether this is a viable construct, versus
>> # eval "$
Hello,
Am Montag, 8. August 2011 19:20:25 UTC+2 schrieb Steven W. Orr:
>
> if (( debug ))
> then
> _debug()
> {
> "$@"
> # I do question whether this is a viable construct, versus
> # eval "$@"
> }
> else
> _debug()
> {
> :
> }
> f
OK. I did a little tracing and found both suggestions from Mr. Williamson
and Mr. Orr very similar.
The differences, Mr. Williamson's example is more simple. Mr. Orr's example
sets the entire _debug function under another if/then statement.
The benefit I found with Mr. Orr's example, if the _d
> On Mon, Aug 08, 2011 at 03:07:15PM -0400, Steven W. Orr wrote:
>
>I didn't mean to go on a rant, but this list here should not be another place
>that discourages people from learning more of the language elements that allow
>us to do better work. Obscure features are in the mind of the uneducat
ogram.
Is this helpful?
Yes.
I've decided to use Mr. Williamson's suggestion:
_debug()
{
[[ $DEBUG != 0 ]]&& "$@"
}
The reply above was very helpful and might provide people searching for
"ifdef style debugging" for Bash further info on inline deb
ply above was very helpful and might provide people searching for
"ifdef style debugging" for Bash further info on inline debugging techniques.
The above does complete the task of inline ifdef style debugging, however, I
think it might confuse or slight hinder readability for som
On 8/8/2011 1:09 PM, Roger wrote:
On Mon, Aug 08, 2011 at 08:56:36AM -0500, Dennis Williamson wrote:
On Mon, Aug 8, 2011 at 3:47 AM, Roger wrote:
I'm doing some research for one of my scripts and always liked the C style
ifdef inline debug statements.
...
Another way to write the _debug() f
> On Mon, Aug 08, 2011 at 08:56:36AM -0500, Dennis Williamson wrote:
>On Mon, Aug 8, 2011 at 3:47 AM, Roger wrote:
>> I'm doing some research for one of my scripts and always liked the C style
>> ifdef inline debug statements.
...
>Another way to write the _debug() function:
>
>#!/bin/bash
>debu
On Mon, Aug 8, 2011 at 3:47 AM, Roger wrote:
> I'm doing some research for one of my scripts and always liked the C style
> ifdef inline debug statements.
>
> The following script seems to work just fine when using the "echo" command
> instead of the currently used "printf" command.
>
> When using
Roger writes:
> [ "${DEBUG}" -ne "0" ] && $@
Missing quotes.
[ "${DEBUG}" -ne 0 ] && "$@"
Andreas.
--
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
I'm doing some research for one of my scripts and always liked the C style
ifdef inline debug statements.
The following script seems to work just fine when using the "echo" command
instead of the currently used "printf" command.
When using "printf", I get something like the following output on st
17 matches
Mail list logo