We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 79c8ae1 commit be14b89Copy full SHA for be14b89
tool/common.sh
@@ -9,11 +9,17 @@ root=$(
9
)
10
echo "Repo root dir: $root"
11
12
-# align GNU vs BSD `sed` version handling -i argument
+# 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.
15
if [[ "$OSTYPE" == "darwin"* ]]; then
- 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"
21
else
- sed="sed -i"
22
+ sed="sed"
23
fi
24
25
function update() {
@@ -26,5 +32,5 @@ function update() {
26
32
expr=${2}
27
33
28
34
echo "Updating ${file} - \"${expr}\""
29
- $sed "${expr}" "$root/$file"
35
+ $sed -i "${expr}" "$root/$file"
30
36
}
0 commit comments