On Fri, Feb 2, 2024 at 4:21 PM Chet Ramey <chet.ra...@case.edu> 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

Reply via email to