Urgent.News

What's breaking now, across thousands of outlets.

Tech

Why a Stop Hook JSON Error Came from printf %b

๐Ÿ“ Originally published (in Japanese) at forge.workstyle.tech . TL;DR The Stop hook reported Unterminated string because printf with %b emitted a raw newline inside a JSON string. The hook also used a cd path fixed to an earlier environment. Its change count missed staged and untracked files when it checked only git diff --name-only . TL;DR The Stop hook error Hook output looks like a JSON objectโ€ฆ

The Stop hook reported an "Unterminated string" error due to the printf commandโ€™s %b format specifier emitting raw newlines inside a JSON string. This occurred because the hook still used a hardcoded cd path from an earlier environment, causing the count of Git changes to miss staged and untracked files. The error message "JSON Parse error: Unterminated string" indicated that the output, although resembling a JSON object, was not valid JSON.

To resolve the issue, the hook was modified to generate JSON using Pythonโ€™s json.dumps function, and its execution location was determined at runtime instead of using a hard-coded cd command. Additionally, the change count was adjusted to include staged and untracked files using git status --porcelain=v1 -z. The revised hook also ensured that the output was valid JSON, even when filenames contained special characters like newlines, quotation marks, backslashes, Japanese text, and spaces.

Written by urgent.news from Dev.to's reporting โ€” not their text. Machine-written โ€” may contain errors; check the original before relying on it.

Read the original at dev.to โ†’

More in Tech

Kanban Tools for Solo Founders: Linear, Plane, and 5 More in 2026

As a solo founder, project management is different from team-based workflows. You don't need real-time collaboration, complex permission systems, or multi-team dashboards.

  • Linear offers fast, keyboard-driven experience with GitHub/GitLab integration.
  • Todoist provides lightweight board view and natural language date parsing.
  • GitHub Projects integrates seamlessly with GitHub-centric workflows.

Why Your Website Needs to Book Calls, Not Just List Hours

Most local business websites are broken in the same quiet way. You list your phone number. You list your email. You list your office hours. Then you wait.

  • Many local business websites lack call booking feature
  • Automated availability system eliminates scheduling friction
  • Benefits industries like plumbing, consulting, real estate

Mastering Stream Stability: A Guide to Rate Control in Restreamers

If you work in broadcasting, you already know that moving video from point A to point B is rarely as simple as connecting a pipe.

  • Rate control manages stream stability by controlling data transmission speed
  • Average mode buffers stream until specific fill level, higher CPU usage
  • TS PCR mode aligns output bitrate with PCR-defined bitrate, highest precision

More from Friday 6 November โ†’