Denys Vlasenko <dvlas...@redhat.com> writes:
> 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.

Or more exactly, the handling of a ")" after a "#" is different from the
handling of a "`" after a "#".  I suspect the parsing is done
differently.  Likely `...` is treated as a quoting operation, and "date
#comment" is first extracted as a string and then parsed.  Whereas it
looks like the parser, upon seeing "$(", does not first scan for ")" but
instead adjusts its context and continues parsing characters.  With that
method, the "#" turns all of "comment)" into comment.

Dale

Reply via email to