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

Re: first adventures

On 10/28/2014 09:05 PM, Bart Schaefer wrote:
} ... so, I finally have my gloriously, deliciously unexpanded, plain
} vanilla command, exactly as I

Well, you think so, but really it just happens that nothing you typed
needed to be metafied.
Deo volente! For now I don't even want to think about metafying, my head would explode.

History is expanded by the lexer as each word is consumed, because as
I mentioned in private email, the expansion has to be re-analyzed to
correctly tokenize it.  So the previously-discussed point in input.c
where VERBOSE is handled, is the line with history expanded.
Yeah, that's the right form, but at that point, it's so generous, it prints everything the
shell does, like preexec(), and the whole init of the shell.

When prog is non-NULL (the else branch of that if), it contains the
compiled form of the input code, which is already broken up into the
set of commands that will be executed.  There is no human-readable
decomposed form of the individual commands that make up a finished
input event; getpermtext(prog) returns the readable form of the entire
thing, which is the closest you get.
Right, it looks good, and each command is on it's own line;

    $ ls init.c*; ls $PWD/main.* > /tmp/junk
    FILE: init.c LINE: 185
    ls init.c*
    ls $PWD/main.* > /tmp/junk


It's proof against expansion of glob, variables and redirection ... pretty much all I'm thinking of.
bangchar/history is expanded, and so are aliases, but that's good.
So, if there was just some way of matching each line of that output from getpermtext() with the
appropriate command, then I'd be close to the finish line. if, in:

   $ ls main.c; ls init.c; ls version.h

... 'ls init.c' could 'know' that it is command #2 of 3, then I could grab line #2 from getpermtext(), and if I could then assign that to a shell variable, I'd have exactly what I want: each command would have access to the verbatim command line 'segment' that called it (that is, between the semicolons).

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