On 2023-01-24 10:36:05 -0600, David Wright wrote: > On Tue 24 Jan 2023 at 15:34:49 (+0100), Vincent Lefevre wrote: [...] > > 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. > > Well, sure, you've pasted lines into a shell, and they get executed. > I don't think you want to prevent that.
With bracketed paste, the lines remains in the command line at the prompt until the user has typed the [Enter] key to run them. So the user can also type Ctrl-C to prevent any execution (or he can edit the command). For instance, in zsh: cventin:~> foo1 foo2 foo3 If I type [Enter], I get: zsh: command not found: foo1 zsh: command not found: foo2 zsh: command not found: foo3 cventin:~[127]> But instead of [Enter], if I type Ctrl-C, I just get: cventin:~[1!]> Nothing has been executed. (The exit code 1 is strange and may be caused by a bug in some hook. This occurs only if I do a Ctrl-C directly after a paste, otherwise I get 130 as expected.) > In terms of accidents, you've just driven a car at a brick wall, > and it runs into it, as expected. No, with modern shells, bracketed paste is precisely there to avoid such kind of issues. -- 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)