From a1ddf0924ba51fb2a6ddff27c891df0b09ce7f37 Mon Sep 17 00:00:00 2001 From: Gabriel Le Breton Date: Tue, 25 Jun 2024 10:31:21 -0400 Subject: [PATCH] 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. --- src/scripts/macos/prepare-env.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/scripts/macos/prepare-env.sh b/src/scripts/macos/prepare-env.sh index de0e40a..244ef10 100644 --- a/src/scripts/macos/prepare-env.sh +++ b/src/scripts/macos/prepare-env.sh @@ -11,8 +11,7 @@ printf '%s\n' "export UNITY_EDITOR_PATH=$unity_editor_path" >> "$BASH_ENV" check_and_install_rosetta() { if ! /usr/bin/pgrep oahd &> /dev/null; then echo "Rosetta 2 is not installed. Installing it now..." - softwareupdate --install-rosetta --agree-to-license - if [ $? -eq 0 ]; then + if softwareupdate --install-rosetta --agree-to-license; then echo "Rosetta 2 installed successfully." else echo "Failed to install Rosetta 2." @@ -89,13 +88,13 @@ resolve_unity_serial() { # License provided. elif [ -n "$unity_encoded_license" ]; then printf '%s\n' "No serial detected. Extracting it from the encoded license." - + if ! extract_serial_from_license; then printf '%s\n' "Failed to parse the serial from the Unity license." printf '%s\n' "Please try again or open an issue." printf '%s\n' "See the docs for more details: https://game.ci/docs/circleci/activation#personal-license" return 1 - + else readonly resolved_unity_serial="$decoded_unity_serial" fi @@ -116,7 +115,7 @@ extract_serial_from_license() { # Fix locale setting in PERL. # https://stackoverflow.com/a/7413863 export LC_CTYPE=en_US.UTF-8 - export LC_ALL=en_US.UTF-8 + export LC_ALL=en_US.UTF-8 local unity_license local developer_data @@ -125,7 +124,7 @@ extract_serial_from_license() { unity_license="$(base64 --decode <<< "$unity_encoded_license")" developer_data="$(perl -nle 'print $& while m{)}g' <<< "$unity_license")" encoded_serial="$(cut -c 5- <<< "$developer_data")" - + decoded_unity_serial="$(base64 --decode <<< "$encoded_serial")" readonly decoded_unity_serial @@ -165,4 +164,4 @@ set -x -password "$unity_password" \ -serial "$resolved_unity_serial" \ -logfile /dev/stdout -set +x \ No newline at end of file +set +x