bug-bash
[Top][All Lists]
Advanced

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

Re: Bash 5.3 bug - POSIX process substitution $() handling error with em


From: Robert Elz
Subject: Re: Bash 5.3 bug - POSIX process substitution $() handling error with embedded comments
Date: Mon, 26 Jan 2026 23:36:04 +0700

    Date:        Mon, 26 Jan 2026 13:46:32 +0200
    From:        Jari Aalto <jari.aalto.fi@gmail.com>
    Message-ID:  
<CAOU7Hic8Odr9w2mKq4VgdJMMTo080Xojivbhr31P3cQ1dEGsmw@mail.gmail.com>

This is not a bug,

  |         See code below.
  |         - The old backtics `` work
  |         - The modern $() doesn't

Parsing $() requires parsing the command inside the () in order to locate
that closing ')'.   Parsing that detects the #, from which point everything
to end of line is a comment (including the ')' - chars in comments are
never interpreted).

Backtick parsing is much simpler, just look for the next unescaped backtick
(even quoting doesn't hide them, just \) so everything is quite different in
that case.

  | Fix:
  |         The process substitution is defined in POSIX and
  |         should work identically in both cases.

Almost nothing is identical between backtick and $() command
substitutions (not process substitutions, which are definitely
not defined by POSIX, though bash implements a version).

Every shell I could think of to test gives a syntax error for
the $(#comment) version.   That absolutely guarantees that
even if the standard says something different (which I don't
think it does) it would be wrong, and be corrected in the
next version (if someone tells them about it).

kre



reply via email to

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