On Mon, Aug 14, 2023, 15:29 Chet Ramey wrote:
> On 8/12/23 1:56 PM, Grisha Levit wrote:
> > The newly added support for `! &' uses the previous value of
> > the_printed_command_except_trap or segfaults if none has been made yet:
>
> Thanks for the report. You're Johnny on the spot here -- I hadn't started
> writing tests for this yet
>
Sorry if it was premature. Btw I'm not sure about the fix for this in
https://git.savannah.gnu.org/cgit/bash.git/diff/execute_cmd.c?h=devel&id=b64a7d8c
Running `! &' still causes the previous command (if any) to be displayed in
`jobs' output:
$ : FOO
$ ! &
[1] 3938
$ jobs
[1]+ Done : FOO
I think this can be addressed by having print_simple_command produce at
least an empty string even if the command has no words and no redirections.
---
diff --git a/print_cmd.c b/print_cmd.c
index 30e354d3..2bf271f4 100644
--- a/print_cmd.c
+++ b/print_cmd.c
@@ -965,6 +965,8 @@ print_simple_command (SIMPLE_COM *simple_command)
{
if (simple_command->words)
command_print_word_list (simple_command->words, " ");
+ else
+ cprintf ("");
if (simple_command->redirects)
{