-
Notifications
You must be signed in to change notification settings - Fork 27
Description
Title quoted from the man page.
What I believe this (pretty vague) bug description is referring to is the fact that -x is "shallow".
If I run this command in an es -x session
; fronk
it's going to output
; fronk
{fronk}
# ... output of fronk ...
no matter what fronk actually is. It could be as simple as fn-fronk = echo hi there, or it could be a thousand-line function that does all sorts of complicated nonsense.
This is especially obnoxious in scripts, when functions can often reach line counts in the triple digits, and -x does essentially nothing to help analyze what's happening during execution of that function. This behavior for -x is not all that different from the behavior for -v, and there's already a -v.
The sort of obvious fix is to have -x do a similar thing as -e: set an evalflag that gets passed down the call stack and prints the command in each eval(). This can produce, I think, pretty good output:
; es.old -xc 'for (i = 1 2 3) echo $i'
{for(i=1 2 3)echo $i}
1
2
3
; es.new -xc 'for (i = 1 2 3) echo $i'
{for(i=1 2 3)echo $i}
echo 1
1
echo 2
2
echo 3
3
; es.old -xc '@ x {if {~ $x hi} {echo $x^-ho} {echo um}} hi'
{@ x{if {~ $x hi} {echo $x^-ho} {echo um}} hi}
hi-ho
; es.new -xc '@ x {if {~ $x hi} {echo $x^-ho} {echo um}} hi'
{@ x{if {~ $x hi} {echo $x^-ho} {echo um}} hi}
@ x{if {~ $x hi} {echo $x^-ho} {echo um}} hi
if %closure(x=hi){~ $x hi} %closure(x=hi){echo $x^-ho} %closure(x=hi){echo um}
%closure(x=hi){echo $x^-ho}
echo hi-ho
hi-ho
(This is from a proof-of-concept I have hacked up.) These examples do show how things flow through the commands, and I think this is a lot more useful than the current behavior.
There are quite a few little not-quite-obvious questions around presentation and which exact commands to print vs. not print (e.g., do we print pathsearch? Probably not. But do we print pathsearch if we're evaluating $&whatis? That might be useful.)
So any reasonable pull request would probably want some good thinking and testing around those edge cases before merging.