Skip to content

Commit

Permalink
remove use of readarray in bash scripts, this has compatibility iss…
Browse files Browse the repository at this point in the history
…ues with some versions of MacOS. Use generic alternatives instead.
  • Loading branch information
eeaton committed Jan 22, 2025
1 parent cced2c3 commit 4e49383
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ enable_api() {

# enable all apis in the array
enable_bootstrap_apis() {
readarray -t apis_array <"$PARENT_DIR"/../project_apis.txt
apis_array=( $(cat "$PARENT_DIR/../project_apis.txt") )
for i in "${apis_array[@]}"; do
enable_api "$i"
done
Expand All @@ -193,7 +193,8 @@ enable_persona_roles() {
local __principal=$1
local __arrayfile=$2
local __persona_name=$3
readarray -t roles_array <"$PARENT_DIR/../$__arrayfile"
roles_array=( $(cat "$PARENT_DIR/../$__arrayfile") )

for i in "${roles_array[@]}"; do
if [ "$__persona_name" == "READER" ] && [ "$i" == "roles/storage.objectViewer" ]; then
#Most roles for most persona are project-level, but READER requires one bucket-level role.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,8 @@ document_names=$(echo "$response" | jq -r '.documents[].name' | awk -F '/' '{pri
printf "%s\n" "${document_names}"

# Create an array from the extracted information
readarray -t document_list <<<"$document_names"

# Print the list (optional)
printf "%s\n" "${document_list[@]}"
document_list=()
printf "%s\0" "$document_names" | xargs -0 -n1 bash -c 'document_list+=("$@")' _

# Confirmation prompt
read -r -p "You are about to delete all documents from project '$PROJECT_ID'. Are you sure? [y/N] " response
Expand Down

0 comments on commit 4e49383

Please sign in to comment.