bug-bash
[Top][All Lists]
Advanced

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

Aw: Re: Inline `ifdef style` debugging


From: pjodrr
Subject: Aw: Re: Inline `ifdef style` debugging
Date: Wed, 28 Mar 2012 18:25:41 -0000
User-agent: G2/1.0

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()
>      {
>          :
>      }
> fi
> 

on bash-hackers.org I found this, which I think is the ultimate
method to write a debug-function:

_debug() {
    if $whatever_test_you_prefer; then
        _debug() {
            "$@"
        }
    else
        _debug() {
            :
        }
    fi
    _debug "$@"
}

they call it "collapsing functions":
http://wiki.bash-hackers.org/howto/collapsing_functions

have fun,

  Peter


reply via email to

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