Skip to content

Parse error for $'\'' inside a command substitution #15

Closed

Description

@git-m86

With unbash 5.1.0, an ANSI-C quoted string holding an escaped single quote parses fine on its own, but inside $( … ) the parser loses track of where the substitution ends.

echo $'\''; X                 → no errors, 2 commands
echo $(echo $'\''); X         → "unterminated command substitution", 1 command
echo "$(echo $'\'')"; X       → "unterminated double quote", "unterminated command substitution"
echo "$(echo $'a')"; X        → no errors, 2 commands

Bash 5.3 runs the third line as written. It prints ' and then runs X. So the \' inside $'…' seems to be read as closing the string when it appears within a substitution.

Activity

  1. webpro commented on Oct 15, 2026

    @webpro
    Member

    Thanks for the report. I was working on v6 so this will be included in that major. Let me know if you need it in v5 and I might be able to backport a fix, but ideally you'd give main a shot (also see docs/MIGRATION-v5-to-v6.md). Also note that v6 introduces forEachChild which might be convenient for traversal.

  2. webpro commented on Oct 15, 2026

    @webpro
    Member

    Preview releases are available, e.g. npm i https://pkg.pr.new/unbash@db63c2b

  3. git-m86 commented on Oct 16, 2026

    @git-m86
    Author

    Thanks for the quick fix! No need for a backport: my use fails closed on the parse error, so 5.1.0 is fine for now. We'll move to v6 when it's released. 'forEachChild' will let us drop our hand-written walker, and the elif and glob notes in the migration guide are exactly what I needed to know.

  4. webpro commented on Oct 16, 2026

    @webpro
    Member

    🚀 This issue has been resolved in v6.0.0. See Release 6.0.0 for release notes.

  5. added a commit that references this issue on Oct 20, 2026
    d7c9469
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions