On Thu, 27 Jul 2023, 18:31 Denys Vlasenko, <dvlas...@redhat.com> wrote:

> Try these two commands:
>
> $ echo "Date: `date #comment`"
> Date: Thu Jul 27 10:28:13 CEST 2023
>
> $ echo "Date: $(date #comment)"
> > )"
> Date: Thu Jul 27 10:27:58 CEST 2023
>
>
> As you see, #comment is handled differently in `` and $().
> I think the handling in `` makes more sense.
>

The behaviour of $(…#…) is the obvious result of performing nested bracket
matching in the presence of #…newline comments. Changing it would
necessitate establishing new rules for how brackets are matched inside
comments, and there are many incompatible permutations of how to do so. So
whatever approach is chosen will open a really ugly can o' worms. (Think,
what happens to existing comment that contain brackets? Or backticks? Or
quotes? Or some combination?)

In short, trying to "fix" this will have unintended consequences and likely
break existing valid code.

On the other hand, since everyone has now had 36+ years to update their
scripts to get rid of backticks, maybe it's time to start issuing a warning
when they're used at all? 🤪

-Martin

>

Reply via email to