On 2023-01-22 23:27:11 -0600, David Wright wrote:
> On Mon 23 Jan 2023 at 04:15:38 (+0100), Vincent Lefevre wrote:
> > On 2023-01-21 23:04:30 -0600, David Wright wrote:
> > 
> > > In this case, if I paste the large file, I do see almost the start
> > > of the file (I seem to lose just the first line, which rolls off the
> > > top), and ^C still works, returning to the prompt with return code
> > > 130.
> > > 
> > > (I don't know whether all terminals behave like this: I just use
> > > xterm myself.)
> > 
> > This should work if the terminal and the shell both support
> > bracketed paste.
> 
> Bracketed paste allows me to erase all the input with ^U.
> But I didn't think you needed bracketed paste for ^C to work.

This is not what I meant. The context was the following one:

| The only suggestion I can give is that you start the applications
| concerned with &, so that you get the xterm prompt back.

So, if there is a prompt, the shell will get the large paste
(possibly with some loss of data due to the pty bug), and there
will be no issues with Ctrl-C itself because the shell will have
read all the input data.

However, before the user can type Ctrl-C, the shell will interpret
the characters from the large paste immediately. There are 2 cases:

1. If bracketed paste is supported, then all the characters will just
be interpreted as quoted characters, like if Ctrl-V were typed before
each character. In particular, a newline character will not validate
the command, but will be inserted in the command itself (where it can
appear either as a line break if the shell supports multiline editing,
or as ^J).

2. If bracketed paste is not supported, then a newline character will
validate the command (except if it happens to be in quoted text). So
one will get lots of buggy commands run by the shell, which is the
same issue as the ignored Ctrl-C without the prompt.

For instance, if I paste the following 3 lines

foo1
foo2
foo3

in dash, I get:

$ foo1
foo2
foo3
sh: 1: foo1: not found
$ sh: 2: foo2: not found
$ sh: 3: foo3: not found
$ 

Then I can type Ctrl-C, but it occurs at a prompt with no input yet,
and the 3 commands have already been executed.

-- 
Vincent Lefèvre <vinc...@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

Reply via email to