Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #16168
| Newsgroups | gnu.bash.bug |
|---|---|
| Date | 2020-04-18 13:59 -0700 |
| References | <00547d35-6a4e-bc3d-3845-e1fbf23a6469@quoininc.com> <8b3df1f1-de20-29e4-676b-7b8e8162ef8e@case.edu> <mailman.359.1586986537.3066.bug-bash@gnu.org> |
| Message-ID | <a60cbe33-aafa-4a6d-ab13-d0edb9951576@googlegroups.com> (permalink) |
| Subject | Re: [bug] PROMPT_COMMAND is not executed as expected in some situations |
| From | ami@fischman.org |
(found this thread as I was about to report the same issue around
edit-and-execute-command)
On Wednesday, April 15, 2020 at 2:35:39 PM UTC-7, Chet Ramey wrote:
> On 4/15/20 2:59 PM, Franklin, Jason wrote:
> > I have discovered that PROMPT_COMMAND is not executed before the
> > printing of PS1 in the following three situations:
> PROMPT_COMMAND is printed before PS1 when the shell goes to read a command.
> (When you're using readline, readline prints the prompt initially, but
> PROMPT_COMMAND works whether you're using editing or not.) That isn't true
> in any of these cases.
[...]
> In cases 1 and 3, that all takes place within a single call to readline(),
> even before the shell receives and tries to parse any of the line.
For the case of:
$ PROMPT_COMMAND='echo "last command was: $(history 1)"'
$ echo hello
hello
last command was: 39744 echo hello
$ <c-x c-e>echo hello2<c-x c-s c-x c-c>
echo hello2
hello2
$
Are you saying that the last line ("$ ") is printed as part of the same call
to readline that emitted the previous ("$ ")?
Unsure if related, but also quite confusing that $? doesn't hold the exit status of commands run through edit-and-execute-command:
$ <c-x c-e>false<c-x c-s c-x c-c>
false
~ $ echo $?
0
Cheers,
-a
Back to gnu.bash.bug | Previous | Next — Previous in thread | Find similar
Re: [bug] PROMPT_COMMAND is not executed as expected in some situations Chet Ramey <chet.ramey@case.edu> - 2020-04-15 17:35 -0400 Re: [bug] PROMPT_COMMAND is not executed as expected in some situations ami@fischman.org - 2020-04-18 13:59 -0700
csiph-web