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

command tails



Bart sez make a new thread so here it is.


If in the example above the tail is 'arg', then it should also be
'arg' in the following example:

    % list=(arg)
    % my_function $list

>>	No, positively not, the tail is "$list" -- the literal text unexpanded.

This contradicts what you described earlier. If this is not enough,
consider yet another example:

    % ls
    my_function xyz
    % *

What is tail here?

>>	It's "xyz" -- again, the unexpanded literal.
 And one intuitively sees that zle will be a good candidate for a solution
because once ENTER is pressed, what it has in it's buffer must needs be
a sequence of raw keystrokes.
Indeed, if you need the raw command as it was typed, you can get it from zle.

>>	But first Bart had some suggestions from yesterday, I want to play with them first.


But, broken by semicolons so that chained commands know
where their own tail ends.
Let's see if this makes sense.

    % alias -g sep='hi ; echo'
    % echo sep bye

What do you want to capture when the last line gets executed?

>>	Too Byzantine, I'm never going to run into any such issue.  'my_function' should report the literal keystrokes that follow it, terminated by ENTER (or a semicolon, whichever come first).  Whatever would be sent to history (but broken by semicolons if possible).  The theoretical aspects are interesting but really this is a question of gritty practicalities.  '% print -rS' knows what I'm looking for.  Obviously things can't be expanded before writing to history!  I'd like to be able to access that unexpanded form without doing it via history if possible and, in the best of all possible worlds, even being able to 'break up' chained commands (but it's not important cuz I'm never actually going to chain my commands; I just think that in principal it should be possible for any command to 'see' it's unexpanded tail).

But first, a short diversion.




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