bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: comments inside command subst are handled inconsistently


From: Dale R. Worley
Subject: Re: comments inside command subst are handled inconsistently
Date: Thu, 27 Jul 2023 15:35:56 -0400

Denys Vlasenko <dvlasenk@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

[Prev in Thread] Current Thread [Next in Thread]