Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix conditional syntax issue in macOS libusb check #9384

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

voronor
Copy link

@voronor voronor commented Nov 22, 2024

Description:

This pull request addresses a minor but important syntax issue in the conditional statement used to check for the presence of libusb on macOS. Specifically, the original condition:

if [[ "$OSTYPE" =~ ^darwin ]] && [[ ! -f /usr/local/opt/libusb/lib/libusb-1.0.0.dylib && ! -f /opt/homebrew/opt/libusb/lib/libusb-1.0.0.dylib ]]; then

contains a logical expression within a single pair of square brackets [[ ... ]] that includes two independent checks joined by &&. This can potentially lead to incorrect interpretation or unexpected behavior.

Issue:

The [[ ... ]] syntax in bash doesn't support nested square brackets directly. The correct approach is to separate the two conditions into individual [[ ... ]] blocks for clarity and to ensure they are evaluated independently.

Fix:

The corrected version separates the conditions as follows:

if [[ "$OSTYPE" =~ ^darwin ]] && [[ ! -f /usr/local/opt/libusb/lib/libusb-1.0.0.dylib ]] && [[ ! -f /opt/homebrew/opt/libusb/lib/libusb-1.0.0.dylib ]]; then

Importance:

Without this fix, the script could potentially misbehave on macOS systems where libusb is missing. By splitting the conditions into distinct checks, we ensure that each path is evaluated correctly, preventing errors in the execution of the script.

Change Summary:

  • Refactored the conditional logic checking the presence of libusb to ensure proper evaluation of separate conditions.

Thank you for maintaining this project! Let me know if you need any further changes or clarification.

This pull request addresses a minor but important syntax issue in the conditional statement used to check for the presence of libusb on macOS.
@grandizzy
Copy link
Collaborator

likely related #1528

@voronor
Copy link
Author

voronor commented Nov 22, 2024

likely related #1528

Completely different error. Read the description again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants