* Line numbers and debugging verbosity
@ 2018-04-09 5:19 Bart Schaefer
2018-04-09 15:51 ` Ray Andrews
0 siblings, 1 reply; 2+ messages in thread
From: Bart Schaefer @ 2018-04-09 5:19 UTC (permalink / raw)
To: Zsh Users
On Fri, Apr 6, 2018 at 9:29 AM, Ray Andrews <rayandrews@eastlink.ca> 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@eastlink.ca> 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.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Line numbers and debugging verbosity
2018-04-09 5:19 Line numbers and debugging verbosity Bart Schaefer
@ 2018-04-09 15:51 ` Ray Andrews
0 siblings, 0 replies; 2+ messages in thread
From: Ray Andrews @ 2018-04-09 15:51 UTC (permalink / raw)
To: zsh-users
On 08/04/18 10:19 PM, Bart Schaefer wrote:
> functions -T test1
Not working yet, but I know what to research, so it will work shorty.
Anyway, the idea is not a full debug, just some helpful indication where
a message comes from. I can't stand it when I see some message and have
no idea who is sending it to me, thereottabealaw!
> warningmsg() {
> print -n "${funcfiletrace[1]}: " && magline "$*"
> }
Marvellous. Perfect, right out of the box, no need for any alias at
all. Why don't they know about this on the internet? There's many
queries about line numbers, but the answer is always the alias.
> 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.
Sure, *once* we're back with functions, it's easy. Once any need for
an alias to capture the line numbers is gone, all problems vanish.
Ironically, last night I figured out how to make it work with aliases
too, but the above is vastly better anyway. It's pleasing to know that
the extra strictness of '5.5 has not really robbed me of any
functionality, just stopped me from doing things a way that I know
perfectly well is bogus.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-04-09 15:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-09 5:19 Line numbers and debugging verbosity Bart Schaefer
2018-04-09 15:51 ` Ray Andrews
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).