Re: remove empty '' in ${var@Q} result?

2023-08-20 Thread Clark Wang
On Wed, Nov 8, 2017 at 9:46 PM Chet Ramey  wrote:

> On 11/7/17 11:38 PM, Clark Wang wrote:
>
> > I made a patch (also attached). Please see if it's ok.
> >
> >
> > Updated by dealing with empty strings (and malloc'ing 2 more bytes)
> > though I'm not sure if it's necessary since the func
> > sh_quote_reusable() already handles empty strings.
> >
> >
> > Hi Chet, do you have a look at my patch?
>
> I did. It's on the list of possible things for the next version. Since it's
> only a cosmetic issue, it's not a high priority.
>

Hi Chet,

Is it possible to fix this in 5.3?


Re: !& error

2023-08-20 Thread Grisha Levit
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)
 {