Files
bun.sh/test/internal/ban-limits.json
robobun 93910f34da Fix bin linking to atomically normalize CRLF in shebang lines (#23360)
## Summary

This PR improves the correctness of bin linking by atomically
normalizing `\r\n` to `\n` in shebang lines when linking bins.

### Changes

- **Refactored shebang normalization in `src/install/bin.zig`**:
  - Extracted logic into separate `tryNormalizeShebang` function
  - Changed from in-place file modification to atomic file replacement
- Reads entire file, creates temporary file with corrected shebang, then
atomically renames
  - Properly cleans up temporary files on errors
  
- **Added test coverage**:
- New test file `test/cli/install/shebang-normalize.test.ts` verifies
CRLF normalization works correctly
- Modified existing test in `bun-link.test.ts` to use Python script with
CRLF shebang

### Why

The previous implementation modified files in-place by seeking to the
`\r` position and overwriting with `\n`. This could potentially corrupt
files if interrupted mid-write. The new atomic approach ensures file
integrity by writing to a temporary file first, then renaming it to
replace the original.

## Test plan

-  `bun bd test test/cli/install/shebang-normalize.test.ts` - passes
-  Verified bins with CRLF shebangs are normalized to LF during linking
-  Code compiles successfully

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Bot <claude-bot@bun.sh>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2025-10-08 01:51:25 -07:00

45 lines
1.1 KiB
JSON

{
" != undefined": 0,
" == undefined": 0,
" catch bun.outOfMemory()": 0,
"!= alloc.ptr": 0,
"!= allocator.ptr": 0,
".arguments_old(": 265,
".jsBoolean(false)": 0,
".jsBoolean(true)": 0,
".stdDir()": 41,
".stdFile()": 16,
"// autofix": 166,
": [^=]+= undefined,$": 256,
"== alloc.ptr": 0,
"== allocator.ptr": 0,
"@import(\"bun\").": 0,
"EXCEPTION_ASSERT(!scope.exception())": 0,
"JSValue.false": 0,
"JSValue.true": 0,
"alloc.ptr !=": 0,
"alloc.ptr ==": 0,
"allocator.ptr !=": 1,
"allocator.ptr ==": 0,
"global.hasException": 28,
"globalObject.hasException": 47,
"globalThis.hasException": 125,
"std.StringArrayHashMap(": 1,
"std.StringArrayHashMapUnmanaged(": 11,
"std.StringHashMap(": 0,
"std.StringHashMapUnmanaged(": 0,
"std.Thread.Mutex": 1,
"std.debug.assert": 26,
"std.debug.dumpStackTrace": 0,
"std.debug.print": 0,
"std.enums.tagName(": 2,
"std.fs.Dir": 168,
"std.fs.File": 62,
"std.fs.cwd": 104,
"std.log": 1,
"std.mem.indexOfAny(u8": 0,
"std.unicode": 27,
"undefined != ": 0,
"undefined == ": 0,
"usingnamespace": 0
}