Skip to content

fix: Make 'sed` command cross-platform. - #439

Open
nguyenpanda wants to merge 2 commits into
overleaf:masterfrom
nguyenpanda:master
Open

fix: Make 'sed` command cross-platform.#439
nguyenpanda wants to merge 2 commits into
overleaf:masterfrom
nguyenpanda:master

Conversation

@nguyenpanda

@nguyenpanda nguyenpanda commented Aug 20, 2026

Copy link
Copy Markdown

Fix bin/init::set_up_config_files error on macOS due to sed implementation differences on BSD.

Error encountered on macOS:
sed: 1: "...": extra characters at the end of n command

Reference:
StackOverflow: sed command with -i option in place editing works fine on Ubuntu but not Mac

Description

This PR fixes a cross-platform scripting issue in bin/init. The -i (in-place) flag behaves differently between GNU sed (Linux) and BSD sed (macOS).

On macOS, BSD sed requires a space between the -i flag and the backup extension (or empty string), whereas GNU sed requires no space. The previous implementation (sed -i'') caused the script to fail on macOS. This update implements a cross-platform approach so the configuration files generate successfully on both Linux and macOS environments.

Related issues / Pull Requests

N/A

Contributor Agreement

…mentation differences on BSD.

**Error encountered on macOS:**
`sed: 1: "...": extra characters at the end of n command`

**Reference:**
[StackOverflow: sed command with -i option in place editing works fine on Ubuntu but not Mac](https://stackoverflow.com/questions/16745988/sed-command-with-i-option-in-place-editing-works-fine-on-ubuntu-but-not-mac)

## Description

This PR fixes a cross-platform scripting issue in `bin/init`. The `-i` (in-place) flag behaves differently between GNU `sed` (Linux) and BSD `sed` (macOS).

On macOS, BSD `sed` requires a space between the `-i` flag and the backup extension (or empty string), whereas GNU `sed` requires no space. The previous implementation (`sed -i''`) caused the script to fail on macOS. This update implements a cross-platform approach so the configuration files generate successfully on both Linux and macOS environments.
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