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

Glitch with "eval" and "autoload"



torch% oops() { eval autoload -X }
torch% oops 
(eval):1: parse error near `"$@"'
torch% functions
'(eval)' () {
        # undefined
        builtin autoload -X
}
oops () {
        eval autoload -X
}


This happens because bin_typeset() gets the name to be autoloaded from
the "scriptname" global, which at the time autoload was invented was not
modified during intervening "eval" and other internal scopes.

The ancient behavior is restored if the "eval_line_no" option is unset.

What's the right way to get the actual function name?  Climbing up the
fstack looking for strcmp(fsptr->name, "(eval)") != 0 seems pretty ugly,
but the "ineval" global isn't sufficient for e.g. "eval eval autoload -X".



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