Re: Feature request: prompt strings in output from edit-and-execute-command readline function ( was About `M-C-e` expand result `'` failed )

2024-02-06 Thread Zachary Santer
On Tue, Feb 6, 2024 at 3:07 PM Chet Ramey  wrote:

> This is more like sourcing a file with `set -v' temporarily enabled (in
> fact, it's very close to that).
>

Can't imagine POSIX would be amenable to all the 'set -v' output lines
being prepended with PS2s, but that actually suffers from the same
ambiguity if stdout and stderr are going to the same place. Not that people
use 'set -v' enough to complain.


Re: Feature request: prompt strings in output from edit-and-execute-command readline function ( was About `M-C-e` expand result `'` failed )

2024-02-06 Thread Chet Ramey

On 2/6/24 1:39 PM, Oğuz wrote:
On Tuesday, February 6, 2024, Chet Ramey > wrote:


What's the specific request here?


That bash interpret multiline commands retrieved from command history as a 
whole and not run the rest of the lines as separate commands when the first 
line is changed.


Ah, I see: you want any "lines" that readline returns that contain embedded
newlines to be parsed as a compound_list instead of a series of newline-
terminated commands (what bash calls a simple_list). Kind of like they had
been enclosed in braces. I'm not sure I could do that much violence to the
parser.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/




Re: Feature request: prompt strings in output from edit-and-execute-command readline function ( was About `M-C-e` expand result `'` failed )

2024-02-06 Thread Chet Ramey

On 2/3/24 10:18 PM, Zachary Santer wrote:


While I'm making feature requests.

I hit C-x C-e and enter the following into my editor:

var='duck'
declare -p var
(
   var='squirrel'
   declare -p var
)
declare -p var

I save that and exit my editor, and this is what I get in the terminal:

zsant@Zack2021HPPavilion MINGW64 ~
$
var='duck'
declare -p var
declare -- var="duck"
(
   var='squirrel'
   declare -p var
)
declare -- var="squirrel"
declare -p var
declare -- var="duck"

Kinda confusing, right?

I could see adding PS1 and PS2 prompts where they would've been, had I 
typed all my commands into the terminal directly. PS2 prompts in front of 
everything that was entered in the editor might be preferable, though, 
given the complex PS1s you see sometimes.


I'd have to think about it. This isn't interactive input read from the
keyboard, where you'd expect to get a prompt. This is more like sourcing
a file with `set -v' temporarily enabled (in fact, it's very close to
that).

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/




Re: Feature request: prompt strings in output from edit-and-execute-command readline function ( was About `M-C-e` expand result `'` failed )

2024-02-06 Thread Oğuz
On Tuesday, February 6, 2024, Chet Ramey  wrote:
>
> What's the specific request here?
>

That bash interpret multiline commands retrieved from command history as a
whole and not run the rest of the lines as separate commands when the first
line is changed. Try it yourself; run a multiline command, recall it and
edit the first line to introduce a syntax error and hit enter. Does it look
right? Wouldn't it be much better if the entire command were discarded?


-- 
Oğuz


Re: Feature request: prompt strings in output from edit-and-execute-command readline function ( was About `M-C-e` expand result `'` failed )

2024-02-06 Thread Chet Ramey

On 2/3/24 10:43 PM, Oğuz wrote:


I want to make one too. Multiline commands retrieved from history can be
short-circuited like this:

   $ ls
   x  y
   $ echo '
   > rm *
   > ' >z
   $
   $ ls
   x  y  z
   $ echo ''
   rm *
   ' >z

   > ^C
   $ ls
   $

After the second invocation of `ls' I add a single quote and hit enter
accidentally, and lose all my files. I wish it didn't happen


What's the specific request here?


--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/




Re: Feature request: prompt strings in output from edit-and-execute-command readline function ( was About `M-C-e` expand result `'` failed )

2024-02-03 Thread Oğuz
On Sunday, February 4, 2024, Zachary Santer  wrote:
>
> While I'm making feature requests.
>

I want to make one too. Multiline commands retrieved from history can be
short-circuited like this:

  $ ls
  x  y
  $ echo '
  > rm *
  > ' >z
  $
  $ ls
  x  y  z
  $ echo ''
  rm *
  ' >z

  > ^C
  $ ls
  $

After the second invocation of `ls' I add a single quote and hit enter
accidentally, and lose all my files. I wish it didn't happen


-- 
Oğuz


Feature request: prompt strings in output from edit-and-execute-command readline function ( was About `M-C-e` expand result `'` failed )

2024-02-03 Thread Zachary Santer
On Fri, Feb 2, 2024 at 4:21 PM Chet Ramey  wrote:

> OK, I'll take that as a feature request for a future version.
>

While I'm making feature requests.

I hit C-x C-e and enter the following into my editor:

var='duck'
declare -p var
(
  var='squirrel'
  declare -p var
)
declare -p var

I save that and exit my editor, and this is what I get in the terminal:

zsant@Zack2021HPPavilion MINGW64 ~
$
var='duck'
declare -p var
declare -- var="duck"
(
  var='squirrel'
  declare -p var
)
declare -- var="squirrel"
declare -p var
declare -- var="duck"

Kinda confusing, right?

I could see adding PS1 and PS2 prompts where they would've been, had I
typed all my commands into the terminal directly. PS2 prompts in front of
everything that was entered in the editor might be preferable, though,
given the complex PS1s you see sometimes.

PS1s and PS2s:

zsant@Zack2021HPPavilion MINGW64 ~
$ var='duck'

zsant@Zack2021HPPavilion MINGW64 ~
$ declare -p var
declare -- var="duck"

zsant@Zack2021HPPavilion MINGW64 ~
$ (
>   var='squirrel'
>   declare -p var
> )
declare -- var="squirrel"

zsant@Zack2021HPPavilion MINGW64 ~
$ declare -p var
declare -- var="duck"

All PS2s:

> var='duck'
> declare -p var
declare -- var="duck"
> (
>   var='squirrel'
>   declare -p var
> )
declare -- var="squirrel"
> declare -p var
declare -- var="duck"

I do think I prefer all PS2s, myself. Makes a distinction between things
entered in a text editor with edit-and-execute-command and things entered
directly on the command line, and also makes a distinction between commands
and their output.

Would be nice.

Zack