[Top][All Lists]

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

Re: Inline `ifdef style` debugging

From: Roger
Subject: Re: Inline `ifdef style` debugging
Date: Wed, 14 Sep 2011 21:04:50 -0800
User-agent: Mutt/1.5.21 (2010-09-15)

>if (( debug ))
>     _debug()
>     {
>         "$@"
>         # I do question whether this is a viable construct, versus
>         # eval "$@"
>     }
>     _debug()
>     {
>         :
>     }
>2. The other thing is that instead of
>at the beginning of the file, you can just say:
>#! /bin/bash
>: ${debug:=0}  # or false or whatever feels good.
>Then when you want to run the program with debug turned on, just say:
>debug=1 prog with various args

OK. I've done something similar to the above, however...

If the following command gets passed through "eval" (as noted above), The
backslash in ' printf "\n" ' gets dropped and the 'n' is printed out.

    _debug printf "size=%s\n" ${size}

As such, no newline is printed to stdout.  If I omit the "eval" command and
just use address@hidden (or $"@", "$@", ...) by itself, then the printf 
interprets the
newline escape (ie. '\n') just fine.


reply via email to

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