fix: make script compatible with bash 3.2 (macOS default)#1
Open
sanderversluys wants to merge 3 commits intomainfrom
Open
fix: make script compatible with bash 3.2 (macOS default)#1sanderversluys wants to merge 3 commits intomainfrom
sanderversluys wants to merge 3 commits intomainfrom
Conversation
Replace associative array (declare -A) with parallel indexed arrays and helper functions. The -A flag requires bash 4.0+, but macOS ships with bash 3.2.57 due to GPLv3 licensing. Changes: - Replace PORT_ASSIGNMENTS associative array with PORT_ASSIGNMENT_KEYS and PORT_ASSIGNMENT_VALUES indexed arrays - Add helper functions: port_set, port_get, port_has, port_keys_sorted - Update all references throughout the script This allows the script to run on stock macOS without requiring users to install a newer bash version.
Use ${array[@]+"${array[@]}"} pattern to safely iterate over
potentially empty arrays when 'set -u' (nounset) is enabled.
readarray/mapfile is bash 4+. Use while read loop instead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
declare: -A: invalid optionerror on macOS systems using the default bash 3.2declare -A) with parallel indexed arrays and helper functions-Aflag requires bash 4.0+, but macOS ships with bash 3.2.57 due to GPLv3 licensingChanges
PORT_ASSIGNMENTSassociative array withPORT_ASSIGNMENT_KEYSandPORT_ASSIGNMENT_VALUESindexed arraysport_set,port_get,port_has,port_keys_sortedTest plan
shipyard initon macOS with default bash 3.2shipyard listto verify port assignments are saved/loaded correctly