Skip to content

Commit be14b89

Browse files
Scripts: fix set version on macOS #126
1 parent 79c8ae1 commit be14b89

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

tool/common.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,17 @@ root=$(
99
)
1010
echo "Repo root dir: $root"
1111

12-
# align GNU vs BSD `sed` version handling -i argument
12+
# macOS includes the BSD version of sed, which uses a different syntax than the
13+
# GNU version, which these scripts expect. So require users of this script to
14+
# install gsed.
1315
if [[ "$OSTYPE" == "darwin"* ]]; then
14-
sed="sed -i ''"
16+
if ! command -v gsed &>/dev/null; then
17+
echo "Error: gsed is required but not installed. Install it, for example using 'brew install gsed'."
18+
exit 1
19+
fi
20+
sed="gsed"
1521
else
16-
sed="sed -i"
22+
sed="sed"
1723
fi
1824

1925
function update() {
@@ -26,5 +32,5 @@ function update() {
2632
expr=${2}
2733

2834
echo "Updating ${file} - \"${expr}\""
29-
$sed "${expr}" "$root/$file"
35+
$sed -i "${expr}" "$root/$file"
3036
}

0 commit comments

Comments
 (0)