Skip to content

Conversation

kundeng
Copy link

@kundeng kundeng commented Aug 9, 2025

Summary

  • Fix sed compatibility issues that occur when users have GNU sed installed (common on macOS via Homebrew)
  • Replace OS-based detection with portable temp file approach
  • Eliminates "can't read s|pattern|replacement|: No such file or directory" errors

Problem

The original code used uname to detect macOS and assumed BSD sed, but:

  • Homebrew users on macOS often install GNU sed as default
  • GNU sed and BSD sed have different -i (in-place) syntax
  • This caused sed to misinterpret replacement patterns as filenames

Solution

  • Use temp file approach: sed pattern file > temp && mv temp file
  • Works consistently across both GNU and BSD sed implementations
  • No more OS-specific conditional logic needed
  • Eliminates backup file syntax differences

Test plan

  • Tested with GNU sed (Homebrew default)
  • Tested with BSD sed (/usr/bin/sed)
  • Verified harbor.sh ln works without errors
  • Confirmed no backup files are created
  • Rebased against latest main branch

Use temp file approach instead of in-place editing to avoid
compatibility issues between GNU sed (-i without space) and
BSD sed (-i with space for backup extension).

This ensures harbor.sh works correctly regardless of which
sed implementation is installed (common issue on macOS with
Homebrew's GNU sed).
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.

2 participants