Skip to content

fix(statusline): handle CRLF input and invalid numeric fields - #1164

Open
bhogesararam23 wants to merge 1 commit into
google-antigravity:mainfrom
bhogesararam23:fix/statusline-windows-crlf-robustness
Open

bhogesararam23 wants to merge 1 commit into
google-antigravity:mainfrom
bhogesararam23:fix/statusline-windows-crlf-robustness

Conversation

@bhogesararam23

Copy link
Copy Markdown

Summary

Fix examples/statusline/statusline.sh failing on Windows when jq produces CRLF-terminated output.

The trailing \r characters were being passed into parsed fields, causing numeric formatting and comparisons to fail and leaving the statusline blank.

This also makes malformed or incomplete statusline input degrade gracefully instead of terminating under set -euo pipefail.

Changes

  • Strip trailing CR characters from parsed fields.
  • Gracefully handle empty, truncated, or partially missing input.
  • Validate numeric fields before formatting and comparison.
  • Clamp percentage values to the valid 0–100 range.
  • Preserve existing behavior for valid LF input.

Validation

Tested with Git Bash and native Windows jq 1.7.1:

  • bash -n — passed
  • Functional regression/edge-case harness — 19/19 passed
  • Native Windows CRLF input — passed
  • LF-input golden comparison against HEAD — 5/5 identical
  • Missing jq fallback — degraded output, exit 0
  • git diff --check — clean

The failing Windows case was reproduced against the unmodified version and verified to render correctly after the fix.

Scope

Only examples/statusline/statusline.sh is modified.

No dependencies are added, and no intentional behavior changes were made for valid Unix/LF input.

@google-cla

google-cla Bot commented Oct 5, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

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.

1 participant