zsh-users
 help / color / mirror / code / Atom feed
* command tails
@ 2023-04-16 15:59 Ray Andrews
  2023-04-16 16:13 ` Roman Perepelitsa
  0 siblings, 1 reply; 2+ messages in thread
From: Ray Andrews @ 2023-04-16 15:59 UTC (permalink / raw)
  To: Zsh Users

[-- Attachment #1: Type: text/plain, Size: 1918 bytes --]

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.


[-- Attachment #2: Type: text/html, Size: 2502 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: command tails
  2023-04-16 15:59 command tails Ray Andrews
@ 2023-04-16 16:13 ` Roman Perepelitsa
  0 siblings, 0 replies; 2+ messages in thread
From: Roman Perepelitsa @ 2023-04-16 16:13 UTC (permalink / raw)
  To: Ray Andrews; +Cc: Zsh Users

On Sun, Apr 16, 2023 at 5:59 PM Ray Andrews <rayandrews@eastlink.ca> wrote:
>
> 'my_function' should report the literal keystrokes that follow it

This requirement is, unfortunately, ill-defined. Consider an analogy.
Provide a function that prints the weight of the command line in
pounds minus its beauty in parsecs.

You can have the full command line unexpanded (grab it from zle) but
you cannot have an unexpanded command line split on semicolons (weight
minus beauty).

Roman.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-04-16 16:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-16 15:59 command tails Ray Andrews
2023-04-16 16:13 ` Roman Perepelitsa

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).