Please see the attached 'autoload.v4' and 'autoload.v4.t'. On Mon, Aug 14, 2017 at 10:30 AM, Chet Ramey <chet.ra...@case.edu> wrote:
> On 8/11/17 6:55 PM, Matthew Persico wrote: > > > What I propose to do between steps 2 and 3 is > > > > 2.1 - After sourcing the function in, type the function to get its text > > 2.2 - type appears to pretty print function code. No matter how sloppy or > > compact your function is on disk, type presents it to you in a particular > > format. To wit, for a function 'foo' > > > > foo is a function > > foo () > > { > > first line of code > > .... > > } > > > > That's regular. Therefore it can be parsed. > > > > 2.3 - With the output of the type command, I strip out line 1 and after > > line 3, I add the text > > > > local AUTOLOADED='foo' > > > > 2.4 - evaling the modified code updates the function to include that line > > > > 2.5 - Determining if a function is autoloaded is as simple as executing > > (something like) > > > > $ type foo | grep 'local AUTOLOADED='foo'. > > > > which is REALLY REALLY fast, even under Cygwin on Windows 10. Yeah, > that's > > one of the environments I'm using for testing. > > > > No more unexportable arrays and hashes. Self documenting. And > 'AUTOLOADED' > > can be changed to something less likely to clash with existing code. And > we > > document that any function you are going to autoload must avoid using the > > variable AUTOLOADED, or whatever it is eventually. > > > > So, before I post code here, what say you all? Is the idea of doing this > > code injection so hideous that it would never be accepted, or is it worth > > submitting the code for perusal? > > Of course it's worth submitting the code for folks to look at. It might be > possible to add a couple more checks to insulate it against possible future > changes to the `type' output. > > -- > ``The lyf so short, the craft so long to lerne.'' - Chaucer > ``Ars longa, vita brevis'' - Hippocrates > Chet Ramey, UTech, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~ > chet/ > -- Matthew O. Persico
autoload.v4
Description: Binary data
autoload.v4.t
Description: Troff document