Skip to content

Commit 234bb22

Browse files
committed
Fix sed script for non-macOS shells
sed -i ‘’ for macOS sed -i for everything else
1 parent d16ae3c commit 234bb22

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

tools/make-safari.sh

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,24 @@ echo -n '*** uBlock0.safariextension: Adding extensions to extensionless assets.
3535
find "$DES"/assets/thirdparties -type f -regex '.*\/[^.]*' -exec mv {} {}.txt \;
3636
echo ''
3737

38+
echo -n '*** uBlock0.safariextension: Generating Info.plist...'
39+
python tools/make-safari-meta.py "$DES"/
40+
echo ''
41+
42+
# Detect OS for sed arguments
43+
if [[ "$OSTYPE" == "darwin"* ]]; then
44+
declare -a sedargs=('-i' '')
45+
else
46+
declare -a sedargs=('-i')
47+
fi
48+
49+
# https://github.com/el1t/uBlock-Safari/issues/15
50+
echo -n '*** uBlock0.safariextension: Correcting ctrl to ⌘ in messages...'
51+
for filename in "$DES"/_locales/*.json; do
52+
sed "${sedargs[@]}" 's/Ctrl/⌘/g' "$filename"
53+
done
54+
echo ''
55+
3856
# Declare __MSG__ scripts inside client-injected.js
3957
# Beware: this removes all newlines within each script
4058
echo -n '*** uBlock0.safariextension: Injecting scripts into vapi-client...'
@@ -51,28 +69,17 @@ awkscript='BEGIN { p = 0 }
5169
gsub(/'"'"'/, "\\'"'"'")
5270
printf "%s", $0
5371
}'
54-
declare -a sedargs=('-i' '')
5572
for message in $(perl -nle '/^\/\/ (__MSG_[A-Za-z]+__)/ && print $1' < "$DES"/js/client-injected.js); do
5673
script=$(awk "${awkscript/__MSG__/${message}}" "$DES"/js/client-injected.js | sed 's/[\"#&]/\\&/g')
5774
sedargs+=('-e' "s#${message}#${script}#")
5875
done
5976
if ! sed "${sedargs[@]}" "$DES"/js/vapi-client.js 2>/dev/null; then
60-
sed ${sedargs[@]} "$DES"/js/vapi-client.js
77+
sed "${sedargs[@]}" "$DES"/js/vapi-client.js
6178
fi
62-
rm -f $DES/js/client-injected.js
63-
echo ''
64-
65-
echo -n '*** uBlock0.safariextension: Generating Info.plist...'
66-
python tools/make-safari-meta.py "$DES"/
67-
echo ''
68-
69-
# https://github.com/el1t/uBlock-Safari/issues/15
70-
echo -n '*** uBlock0.safariextension: Correcting ctrl to ⌘ in messages...'
71-
for filename in "$DES"/_locales/*.json; do
72-
sed -i '' 's/Ctrl/⌘/g' "$filename"
73-
done
79+
rm -f "$DES"/js/client-injected.js
7480
echo ''
7581

82+
# Prepare extension for release
7683
if [ "$1" = all ]; then
7784
if [ ! -f dist/certs/key.pem ] || [ ! -f dist/certs/SafariDeveloper.cer ]; then
7885
echo '*** uBlock0.safariextension: Cannot sign extension; missing credentials'

0 commit comments

Comments
 (0)