Skip to content

Commit a1ddf09

Browse files
authored
Fix preparation script for macOS for shell check (#77)
Replaced `if [ $? -eq 0 ]; then` with `if softwareupdate --install-rosetta --agree-to-license; then` in the `check_and_install_rosetta` function to check the exit status directly.
1 parent b95e9d1 commit a1ddf09

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/scripts/macos/prepare-env.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ printf '%s\n' "export UNITY_EDITOR_PATH=$unity_editor_path" >> "$BASH_ENV"
1111
check_and_install_rosetta() {
1212
if ! /usr/bin/pgrep oahd &> /dev/null; then
1313
echo "Rosetta 2 is not installed. Installing it now..."
14-
softwareupdate --install-rosetta --agree-to-license
15-
if [ $? -eq 0 ]; then
14+
if softwareupdate --install-rosetta --agree-to-license; then
1615
echo "Rosetta 2 installed successfully."
1716
else
1817
echo "Failed to install Rosetta 2."
@@ -89,13 +88,13 @@ resolve_unity_serial() {
8988
# License provided.
9089
elif [ -n "$unity_encoded_license" ]; then
9190
printf '%s\n' "No serial detected. Extracting it from the encoded license."
92-
91+
9392
if ! extract_serial_from_license; then
9493
printf '%s\n' "Failed to parse the serial from the Unity license."
9594
printf '%s\n' "Please try again or open an issue."
9695
printf '%s\n' "See the docs for more details: https://game.ci/docs/circleci/activation#personal-license"
9796
return 1
98-
97+
9998
else
10099
readonly resolved_unity_serial="$decoded_unity_serial"
101100
fi
@@ -116,7 +115,7 @@ extract_serial_from_license() {
116115
# Fix locale setting in PERL.
117116
# https://stackoverflow.com/a/7413863
118117
export LC_CTYPE=en_US.UTF-8
119-
export LC_ALL=en_US.UTF-8
118+
export LC_ALL=en_US.UTF-8
120119

121120
local unity_license
122121
local developer_data
@@ -125,7 +124,7 @@ extract_serial_from_license() {
125124
unity_license="$(base64 --decode <<< "$unity_encoded_license")"
126125
developer_data="$(perl -nle 'print $& while m{<DeveloperData Value\="\K.*?(?="/>)}g' <<< "$unity_license")"
127126
encoded_serial="$(cut -c 5- <<< "$developer_data")"
128-
127+
129128
decoded_unity_serial="$(base64 --decode <<< "$encoded_serial")"
130129
readonly decoded_unity_serial
131130

@@ -165,4 +164,4 @@ set -x
165164
-password "$unity_password" \
166165
-serial "$resolved_unity_serial" \
167166
-logfile /dev/stdout
168-
set +x
167+
set +x

0 commit comments

Comments
 (0)