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

Re: first adventures



On 10/26/2014 10:52 AM, Peter Stephenson wrote:


Peter, Bart:

First hints of traction:

That's how it works for interactive shells. The lowest level of input in the main shell is within input.c. Because zle is a separate library that may be loaded at run time the interaction actually goes through the function zleentry() in init.c, which ensures that either zle is loaded or if it can't be there's some fallback to get the input another way. ZLE_CMD_READ is the command to zleentry() that causes a line to be read. shingetline() is the fallback for non-interactive shells or if zle can't be loaded. va_end(ap);

At the bottom of zleentry():

    ///
    printf("FILE: %s LINE: %d\n", __FILE__, __LINE__);
    puts(ret);
        return ret;

  }

I get:

    $ !4562; ls zsh.*
ls e*; ls zsh.* << exactly as typed, but with bangchar expanded.
    FILE: init.c LINE: 1535
    !4562; ls zsh.*                      << exactly exactly as typed :)

    (output)

... so, I finally have my gloriously, deliciously unexpanded, plain vanilla command, exactly as I typed it. (BTW, 'cmd = -1' and this doesn't seem to be handled by 'ZLE_CMD_READ' but nevermind.) However, as Bart has explained, I really do want to be able to capture the bangchar/history thing expanded
line as well, precisely as shown by the shell anyway:

ls e*; ls zsh.* << exactly as typed, but with bangchar expanded.

Where can I capture that output? AFAICT, that's exactly as it gets written to .histfile, so it should
be easy enough to intercept.

Finally, if we have several commands on one line, at some point the line must be chopped up at the semicolons for execution, since each individual command only 'gets' that part of the line that applies to it. How can that be done? (I was speculating that if each command could somehow know that it was (say) command #3 on that line, then one might very inelegantly parse the .histfile line, counting semicolons, and chop it up that way, but how ugly is that.)



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