Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Line numbers and debugging verbosity

On Fri, Apr 6, 2018 at 9:29 AM, Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
> What I'm actually trying to do is reduce verbosity of a function by
> redefining various message printer functions as null.  It works fine with
> functions, but if the message printers are aliases (which seem to be the
> only way to get:  ${(%):-%x %I} ... line information printed, it seems that
> can't be done in a function) ... then it goes sour.

On Sun, Apr 8, 2018 at 3:38 PM, Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
> Is there a new strategy that might work?  Nullify the function and/or the
> alias?  Really, just some way of stopping messages from printing at all?

There are several possible approaches.  For one, you could stop using
your own "echo"/"print" statements and instead turn tracing on and off
for the surrounding function:

  functions -T test1

If you want to keep printing your own messages instead of using the
xtrace facility, let's get you away from aliases.  The information for
%x and %l are in the $funcfiletrace variable, and will give you the
result you want from inside a function.

  warningmsg() {
    print -n "${funcfiletrace[1]}: " && magline "$*"

For another approach, you had a perfectly good example:

>     [[ "$vverbose" < 3 ]] &&
>     {
>         warningmsg () { ; }
>      }

Just put a similar test in the definition of "warningmsg" e.g.

  warningmsg() {
    (( $dbg )) &&
    print -nr - "${funcfiletrace[1]}: " && magline "$*"

Now you don't have to modify the function, you just assign dbg=1 or dbg=0.

Messages sorted by: Reverse Date, Date, Thread, Author