Skip to content

marketplace-check.sh: case pattern inside $( ) is a syntax error on macOS bash 3.2, so exec aborts silently #763

Closed

Description

@thanarat

Versions: macOS /bin/bash 3.2.57, mxcli v0.31.0, Mendix 11.12.4, toolkit v2026.11.16 (6dad68f), still present on master

What happens

bin/lib/marketplace-check.sh, _mkt_locate (line 115 on current master), runs a case inside a command substitution:

out="$( export PROJECT_ROOT="$root"; . "$_MKT_COMMON" >/dev/null 2>&1 || exit 0
        m="$(find_mpr 2>&1)" && printf 'mpr\t%s\n' "$m" || {
          case "$m" in *"refusing to guess"*) printf 'mpr\tAMBIGUOUS\n' ;; esac; }
        ...
        exit 0 )"

bash 3.2 treats the unbalanced ) of the pattern *"refusing to guess"*) as the end of the $( ). This is the same class of bug as #552 (script-owners), in a different file.

bash -n does not catch it, because bash 3.2 parses the command substitution only when it runs. At run time it prints command substitution: syntax error near unexpected token 'newline', and out holds the rest of the script text instead of the mpr / mx lines. In our project, every bin/exec.sh run on a domain-model script stopped there.

Minimal repro on macOS /bin/bash 3.2.57:

f() { out="$( m="x refusing to guess"; false || {
        case "$m" in *"refusing to guess"*) printf 'A\n' ;; esac; }
        exit 0 )"; echo "OUT=[$out]"; }
f   # syntax error, then OUT=[ printf 'A\n' ;; esac; } ... ]

Steps to reproduce

  1. On macOS, with the stock /bin/bash 3.2.57.
  2. Run bin/exec.sh on any domain-model MDL script, or run the repro above.
  3. You get the syntax error, and the marketplace check never sees the .mpr.

Expected

The marketplace check runs and the exec continues.

Fix (verified locally on bash 3.2 and bash 5)

Use the POSIX leading paren on the pattern:

case "$m" in (*"refusing to guess"*) printf 'mpr\tAMBIGUOUS\n' ;; esac

Activity

  1. MendixMau commented on Nov 16, 2026

    @MendixMau
    Owner

    Triage: FIX track. portability (macOS bash 3.2). Verified by inspection on master 6dad68f: the line is at bin/lib/marketplace-check.sh:115, as reported. The bash 3.2 runtime failure is UNVERIFIED here (no bash 3.2 on this runner), but it is the known #552 class.
    Root cause / Problem: _mkt_locate (bin/lib/marketplace-check.sh:115) runs case "$m" in *"refusing to guess"*) … esac inside $( … ). bash 3.2 reads the pattern's unmatched ) as the end of the command substitution. bash -n does not catch it, and bin/check-portability.sh has no rule for this pattern.
    Value: H. Per the report, every bin/exec.sh run on a domain-model script stops at the marketplace check on stock macOS /bin/bash. That is a hard stop on the main build path for every Mac user.
    Risk of fixing: L. (pattern) is POSIX and behaves the same on bash 3.2, bash 5 and Git Bash. There is no verdict, exit-code or output change apart from the check now working. 0 baseline words.
    Rigidity check: no process, architecture or performance change.
    Process cost (#687): per exec (domain-model scripts). Wall-clock is unchanged, and it removes a hard failure.
    Needs clarification: no
    Learning value: learned rule (portability): a case inside $( ) always uses the leading-paren pattern (pat). This is the second occurrence after #552, so a mechanical check is worth adding.
    Proposed fix:

    • Change the pattern at :115 to (*"refusing to guess"*).
    • Sweep the other case statements inside $( ) under bin/, bin/lib/ and project-bin/ for the same shape.
    • Add a check-portability.sh rule that flags a case pattern without a leading ( inside a command substitution, so a third one can't land.

    Alternative: move the case out of the substitution into a helper function. That is a bigger change for no extra gain.
    Proof: bash -n can't catch this. Either run a small fixture under /bin/bash 3.2 in CI (macOS runner), or use a check-portability fixture with the reporter's minimal repro, which must be flagged on master.
    Effort: XS (the fix) / S (with the lint rule). Recommendation: FIX NOW. Credit thanarat.
    Labels: kind/bug, size/s

    Reply go (FIX) or go option N (DISCUSS). Fix PRs still get independent review and your merge.


    Generated by Claude Code

  2. MendixMau commented on Nov 16, 2026

    @MendixMau
    Owner

    Fix PR opened: #774. The case pattern at marketplace-check.sh:115 now has a leading paren. check-portability.sh gets a new rule 3 so this bug class can't return; the sweep found no other occurrences. Thanks @thanarat for the report and the verified fix. Waiting for an independent review before merge, including the fixtures that couldn't be run here.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions