From 9b1e62c8ea4e4c47d4dba49282893effa1eb775d Mon Sep 17 00:00:00 2001 From: Jeremy Kaplan Date: Tue, 7 Jan 2020 09:18:38 -0800 Subject: [PATCH] Add missing mapfile workaround for Mac --- install | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/install b/install index f1d8baf..875f706 100755 --- a/install +++ b/install @@ -24,10 +24,18 @@ load_config() { OS_NAME="$(uname -s | tr '[:upper:]' '[:lower:]')" -if [ -f "${PROFILES_FILE}" ]; then - mapfile -t profiles < "${PROFILES_FILE}" -else +if [ "$#" -gt 0 ]; then profiles=("${@}") +elif [ -f "${PROFILES_FILE}" ]; then + # MacOS bash 3.2 doesn't have mapfile. Workaround from + # http://mywiki.wooledge.org/BashFAQ/005#Loading_lines_from_a_file_or_stream + unset profiles + while IFS= read -r; do + profiles+=("$REPLY") + done < "${PROFILES_FILE}" + [[ $REPLY ]] && profiles+=("$REPLY") +else + profiles=() fi for conf in default "${OS_NAME}" "${profiles[@]}"; do