Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: option to show file:line everytime echo is called?
On 13/01/17 12:32 AM, Timothee Cour wrote:
turns out Anthony Heading's solution works great (thanks!): alias
echo2='echo ${(%):-%x:%I}'
I have a function 'varis' that does something similar but it uses
$LINENO which reports the line number within the function, but I see
that the above reports the line number within the file which is very
nice for the obvious reason that if you have several functions defined
in one file, you don't constantly have to do the arithmetic of the line
offset from where the function begins in the file. But I'm curious as
to how the above can work, or even how $LINENO works, since, once a
function is sourced, it exists in it's -- don' t know the correct term
-- 'cut down' or 'pure' form with no blank lines or comments (I think),
so how does zsh know/remember what the function looks like in the
original file? Does it go back and check when the above is used or does
it have some way of remembering? That doesn't seem reasonable, still it
works perfectly.
Way down in some file:
xx ()
{
jjunk="This is jjunk"
varis jjunk
echo ${(%):-%x:%I}
}
$ xx
xx, line 7: evaluated: "$jjunk" is: |This is jjunk|
./varis:91
... so the 'echo' knows the true line number and the name of the file
vs. knowing the name of the function and the line within the function.
Nice to have both available!
Messages sorted by:
Reverse Date,
Date,
Thread,
Author