Skip to content

fix(snapshot): assign newline to var before case pattern to avoid tokenize-time split#574

Draft
ManveerBhullar wants to merge 1 commit into
kunchenguid:mainfrom
ManveerBhullar:fix-case-newline-pattern
Draft

fix(snapshot): assign newline to var before case pattern to avoid tokenize-time split#574
ManveerBhullar wants to merge 1 commit into
kunchenguid:mainfrom
ManveerBhullar:fix-case-newline-pattern

Conversation

@ManveerBhullar

@ManveerBhullar ManveerBhullar commented Jul 14, 2026

Copy link
Copy Markdown

Put back into draft as i think this fix isnt proper. double checking it on my local

Problem

$'\n' inside a case pattern expands to a literal newline at tokenize time, splitting the case branch across lines so ;; becomes an unexpected token:

fm-fleet-snapshot.sh: line 690: syntax error near unexpected token `;;
  1. bash -n syntax check passed
  2. fm-bearings-snapshot.sh runs clean (exit 0)
  3. fm-fleet-snapshot.sh --json runs clean (exit 0)
  4. All 12 tests in tests/fm-fleet-snapshot-view.test.sh pass

Edit: forgot to mention I'm on macOS

…enize-time split

$'\n' inside a case pattern expands to a literal newline at tokenize
time, splitting the branch so ;; becomes an unexpected token. Assign
the newline to a variable first so the lexer never sees $'...' in the
pattern position. Both heredoc-trim sites fixed (head and tail).
@zachlandes

Copy link
Copy Markdown

Confirming this one from the field. After a self-update to main, bin/fm-fleet-snapshot.sh stopped parsing at all on macOS system bash (3.2.57):

bin/fm-fleet-snapshot.sh: line 690: syntax error near unexpected token `;;'

bash 3.2 splits $'\n' at tokenize time inside a case pattern, so it's a parse error rather than something that only bites when the truncation branch actually runs. The script dies on every invocation, and it takes fm-fleet-view.sh and fm-bearings-snapshot.sh with it since both call it. I rolled our checkout back to the previous commit to get them working again.

The fix looks correct to me and it covers both call sites (registry_secondmates_json and bounded_parent_activities_json).

@kunchenguid can you merge this? Anyone on stock macOS bash has a broken snapshot after updating.

@ManveerBhullar
ManveerBhullar marked this pull request as draft July 14, 2026 20:53
@kunchenguid

Copy link
Copy Markdown
Owner

quick heads up: i reproduced this on stock macOS Bash 3.2. the current patch still fails to parse before the snapshot code runs, so it doesn't fix the underlying issue and breaks snapshot, fleet view, and Bearings.

i'm working on a separate urgent fix now. it'll replace the problematic nested case blocks and add plain /bin/bash coverage so this doesn't regress.

@kunchenguid

Copy link
Copy Markdown
Owner

quick update: the replacement fix is now up at #578. it removes the Bash 3.2-incompatible nested case pattern and adds stock /bin/bash CI coverage. the full suite is green, including the macOS Bash 3.2 path.

i'm going to continue with that PR and leave this one unmerged. thanks again for catching the underlying issue and putting together the first patch - it helped make the compatibility gap concrete.

@ManveerBhullar

Copy link
Copy Markdown
Author

Awesome, glad you were able to figure this out. sorry for the very sparse PR and bug report :)

btw i sent you a linkedin connection request last week if you want to keep in touch , hope you dont find this rude to bring up here.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants