Skip to content

fix: replace sed -i with perl -pi for macOS compatibility#14990

Merged
skjnldsv merged 1 commit into
masterfrom
fix/sed-macos-compat
Jul 21, 2026
Merged

fix: replace sed -i with perl -pi for macOS compatibility#14990
skjnldsv merged 1 commit into
masterfrom
fix/sed-macos-compat

Conversation

@skjnldsv

Copy link
Copy Markdown
Member

☑️ Resolves

Summary

merge-folders in user_manual/Makefile used sed -i -e to rewrite
_images and _static paths in the built HTML. macOS BSD sed requires
a backup-extension argument with -i (e.g. sed -i ''), while GNU sed
does not accept an empty extension — there is no single flag spelling
that works on both.

Replace both invocations with perl -pi -e, which handles in-place
edits portably on Linux and macOS.

Before:

find ./ -type f -exec sed -i -e 's/_images/..\/_images/g' {} \;
find ./ -type f -exec sed -i -e 's/_static/..\/_static/g' {} \;

After:

find ./ -type f -exec perl -pi -e 's|_images|../_images|g' {} \;
find ./ -type f -exec perl -pi -e 's|_static|../_static|g' {} \;

Note: the add-lang-to-versions-template-% target mentioned in the
issue title was already removed in a prior refactor commit
(c40d359041). The remaining sed -i usage (in merge-folders) is
the last occurrence of this macOS-incompatible pattern.

🖼️ Screenshots

N/A — Makefile change only, no visual output affected.

✅ Checklist

  • I have built the documentation locally and reviewed the output
  • Screenshots are included for visual changes (N/A)
  • I have not moved or renamed pages (or added a redirect if I did)
  • I have run codespell or similar and addressed any spelling issues

@github-actions

github-actions Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

📖 Documentation Preview

🔍 Open preview →

No RST documentation pages changed in this PR.

Last updated: Tue, 21 Jul 2026 08:20:30 GMT

@skjnldsv

Copy link
Copy Markdown
Member Author

ping @alperozturk96 :)

macOS BSD sed requires a backup extension with -i (e.g. sed -i ''),
while GNU sed does not accept an empty extension. The merge-folders
target used sed -i -e which fails on macOS with:

  sed: 1: "<file>": invalid command code .

Replace with perl -pi -e which is portable across both platforms.

Fixes #13186

Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
@alperozturk96
alperozturk96 force-pushed the fix/sed-macos-compat branch from d9daa00 to bb89487 Compare July 21, 2026 07:46

@alperozturk96 alperozturk96 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.

Tested. It works on macOS.

@skjnldsv
skjnldsv merged commit 8700e03 into master Jul 21, 2026
25 checks passed
@skjnldsv
skjnldsv deleted the fix/sed-macos-compat branch July 21, 2026 08:20
@skjnldsv

Copy link
Copy Markdown
Member Author

/backport to stable34

@skjnldsv

Copy link
Copy Markdown
Member Author

/backport to stable32

@skjnldsv

Copy link
Copy Markdown
Member Author

/backport to stable33

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.

Fix sed Command Compatibility Issue in add-lang-to-versions-template-% Target on macOS

2 participants