Skip to content

Strip trailing CRLF from exec() output - #1316

Open
jsskeen-utah wants to merge 1 commit into
dmno-dev:mainfrom
jsskeen-utah:exec-trim-crlf
Open

jsskeen-utah wants to merge 1 commit into
dmno-dev:mainfrom
jsskeen-utah:exec-trim-crlf

Conversation

@jsskeen-utah

@jsskeen-utah jsskeen-utah commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

exec() removed only a trailing \n, so output with a CRLF line ending kept a stray \r. On Windows, Write-Output produces CRLF, so exec("powershell -NoProfile -Command \"Write-Output 'x'\"") resolved to "x\r". The fix removes one trailing LF or CRLF.

The docs already say exec() trims the extra newline that many CLI tools print, so this matches the documented behavior.

Notes

  • Only one trailing line ending is removed, as before. Trailing spaces and leading whitespace are not touched.
  • The new test compares the raw value. The existing functionValueTests helper strips \r before comparing, which is why it didn't catch this bug.

Testing

  • Linux: the full varlock test suite passes (147 files, 2606 tests). The new test fails on main (expected 'moo\r' to be 'moo') and passes with this change. I also packed this branch and installed the tarball: exec("printf 'pwsh-ok\r\n'") resolves to pwsh-ok.
  • Windows: I applied the same one-line change to the varlock 1.25.0 install on a Windows 11 VM and ran exec() with powershell -NoProfile -Command "Write-Output 'pwsh-ok'". Before the change the value ended in byte 13 (\r). After it, the value is pwsh-ok. This was a one-line patch to the installed file, not a run of the packed tarball, so the packed Windows build is still untested.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Approach: sound: removing one trailing LF or CRLF fixes the stray carriage return without trimming other whitespace.

Reviewed changes cover the resolver fix, regression test, and patch release entry.

  • Output normalization: exec() now removes a complete trailing CRLF or LF.
  • Regression coverage: a direct resolved-value assertion avoids the existing helper's carriage-return normalization; all 116 resolver tests passed on Node and Bun on Linux.
  • Release note: documents the Windows line-ending fix.

Pullfrog  | View workflow run | Using gpt-6.1-sol | 𝕏

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant