Skip to content

Conversation

@IsaacG
Copy link
Member

@IsaacG IsaacG commented Sep 25, 2025

No description provided.

@IsaacG IsaacG requested a review from a team as a code owner September 25, 2025 18:28
bin/bootstrap.sh Outdated
Comment on lines 42 to 43
mapfile -t files < <(git grep --files-with-matches replace-this-with-the-track-slug)
sed -i "s/replace-this-with-the-track-slug/${SLUG}/g" "${files[@]}"
Copy link
Contributor

Choose a reason for hiding this comment

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

On second thought, xargs might be better:

Suggested change
mapfile -t files < <(git grep --files-with-matches replace-this-with-the-track-slug)
sed -i "s/replace-this-with-the-track-slug/${SLUG}/g" "${files[@]}"
git grep --null --files-with-matches replace-this-with-the-track-slug) \
| xargs --null sed -i "s/replace-this-with-the-track-slug/${SLUG}/g"

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not generally a huge fan of xargs. Is there anything wrong with passing the files to sed? I really don't think we need to protect against newlines in the file names here.

Copy link
Contributor

Choose a reason for hiding this comment

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

and it's very unlikely we'll find thousands of filenames.

@ErikSchierboom
Copy link
Member

I've tried running the bootstrap script on my Mac (which Jeremy and I both use), and I got:

erik@Eriks-MacBook-Pro-2 generic-test-runner % LANGUAGE=Fake SLUG=fake bin/bootstrap.sh
bin/bootstrap.sh: line 42: mapfile: command not found

@IsaacG
Copy link
Member Author

IsaacG commented Sep 28, 2025

I've tried running the bootstrap script on my Mac (which Jeremy and I both use), and I got:

erik@Eriks-MacBook-Pro-2 generic-test-runner % LANGUAGE=Fake SLUG=fake bin/bootstrap.sh
bin/bootstrap.sh: line 42: mapfile: command not found

mapfile was added to bash 4.4 in 2016. The "default" bash on Mac is pinned to bash 3 (2005).

Is bash 3 the target shell here? What about the Docker scripts -- should those target POSIX sh? Or can those target modern bash if they run on a modern Linux image?

@glennj
Copy link
Contributor

glennj commented Sep 28, 2025

Working on a Mac, we'll also have trouble with sed -i that requires an argument on the BSD-ish Mac sed.

We do need to establish a baseline set of tools.

@ErikSchierboom
Copy link
Member

Working on a Mac, we'll also have trouble with sed -i that requires an argument on the BSD-ish Mac sed.
We do need to establish a baseline set of tools.

Anything that maintainers like Jeremy and I use must work on Macs. The scripts that run in Docker images can likely use more modern version of bash. 95% of the time, the base Docker image that people use is Alpine or Ubuntu. If we can target the scripts to run there, we'll be fine.

@glennj
Copy link
Contributor

glennj commented Sep 29, 2025

Working on a Mac, we'll also have trouble with sed -i that requires an argument on the BSD-ish Mac sed.
We do need to establish a baseline set of tools.

Anything that maintainers like Jeremy and I use must work on Macs. The scripts that run in Docker images can likely use more modern version of bash. 95% of the time, the base Docker image that people use is Alpine or Ubuntu. If we can target the scripts to run there, we'll be fine.

@ErikSchierboom are you OK being told to go install a modern bash from homebrew?

@IsaacG we can just replace sed with perl, it's installed everywhere.

perl -i "s/replace-this-with-the-track-slug/${SLUG}/g" "${files[@]}"

@ErikSchierboom
Copy link
Member

I'm fine with that if Jeremy is too

@IsaacG
Copy link
Member Author

IsaacG commented Sep 30, 2025

Sounds like we need input from @iHiD here :)

I haven't written Perl in about a decade and I'm not a fan but we can totally swap sed for perl if that's more compatible!

@IsaacG
Copy link
Member Author

IsaacG commented Oct 9, 2025

@ErikSchierboom Any last thoughts before merging?

@glennj
Copy link
Contributor

glennj commented Oct 9, 2025

A thought about mapfile and bash 3.2 on the Mac: we can add a check into the script for the minimum required version:

if (( "${BASH_VERSINFO[0]}${BASH_VERSINFO[1]}" < 44 )); then
    echo "This script requires bash version 4.4 at minimum." >&2
    echo "You can install a modern bash from Homebrew - https://brew.sh" >&2
    exit 1
fi

@ErikSchierboom
Copy link
Member

@ErikSchierboom Any last thoughts before merging?

I need to test that it works :)

Copy link
Member

@ErikSchierboom ErikSchierboom left a comment

Choose a reason for hiding this comment

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

One last suggestion and then we're good

Co-authored-by: Erik Schierboom <[email protected]>
@IsaacG IsaacG merged commit 0dce056 into exercism:main Oct 12, 2025
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.

3 participants