Skip to content

Commit 6a4169f

Browse files
committed
Make the init tool compatible with BSD
1 parent 95b4b45 commit 6a4169f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

tools/init.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ set -eu
66

77
ACTIONS_WORKFLOW=pages-deploy.yml
88

9+
TEMP_SUFFIX="to-delete" # temporary file suffixes that make `sed -i` compatible with BSD and Linux
10+
911
help() {
1012
echo "Usage:"
1113
echo
@@ -61,12 +63,15 @@ init_files() {
6163
_workflow=".github/workflows/${ACTIONS_WORKFLOW}"
6264
_default_branch="$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')"
6365
_lineno="$(sed -n "/branches:/=" "$_workflow")"
64-
sed -i "$((_lineno + 1))s/- .*/- ${_default_branch}/" "$_workflow"
66+
67+
sed -i.$TEMP_SUFFIX "$((_lineno + 1))s/- .*/- ${_default_branch}/" "$_workflow"
68+
rm -f "$_workflow.$TEMP_SUFFIX"
6569

6670
fi
6771

6872
# trace the gem lockfile on user-end
69-
sed -i "/Gemfile.lock/d" .gitignore
73+
sed -i.$TEMP_SUFFIX "/Gemfile.lock/d" .gitignore
74+
rm -f ".gitignore.$TEMP_SUFFIX"
7075

7176
# remove the other fies
7277
rm -f .travis.yml

0 commit comments

Comments
 (0)