Skip to content

safe-bash: closed legacy backticks abort the outer script on compound-list EOF #702

Description

@kamilio

Closed legacy-backtick command substitutions currently turn an incomplete compound command inside the substitution into an eager parse failure for the entire outer script.

Reproduction:

printf 'BEFORE\n'; value=`if`; code=$?; printf 'STATUS:%s VALUE:<%s>\n' "$code" "$value"; printf 'AFTER\n'

Current behavior: parseShell throws ShellSyntaxError: Expected nonempty compound list, and Shell.exec exits 2 before the outer script runs.

GNU Bash 5.2.37 behavior: the closed substitution reports its own unexpected-EOF diagnostic and status 2, while the outer script continues:

BEFORE
STATUS:2 VALUE:<>
AFTER

This was reproduced in the trace-shell compatibility work with both MemoryFS and mock S3. The behavioral RED had 9 focused failures: simple and nested legacy backticks, diagnostic line context, both filesystem backends, and substitution-depth preservation.

The fix should defer only positively identified compound-list EOF errors inside a closed ordinary backtick. It must keep top-level input, $() substitutions, unclosed backticks, unrelated syntax errors, heredoc behavior, and nesting/substitution limits unchanged. Add parser and runtime regression coverage for simple and nested cases on MemoryFS and mock S3.

A pending local candidate passes the focused compatibility checks but is not on origin/main or released.

Activity

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

    bugSomething is not working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions