From b7c0dad24210024bfb0ef847482317d03355d332 Mon Sep 17 00:00:00 2001 From: Pete Woods Date: Fri, 28 Aug 2020 12:48:54 +0100 Subject: [PATCH] Remove mapfile use - This makes it compatible with the version of BASH shipped with macOS --- sshenc.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/sshenc.sh b/sshenc.sh index 1c08988..4374d69 100755 --- a/sshenc.sh +++ b/sshenc.sh @@ -69,13 +69,12 @@ if [[ "${#github_handle[@]}" -gt 0 ]]; then do curl -s "https://github.com/$handle.keys" | grep ssh-rsa > "$temp_dir/$handle" if [ -s "$temp_dir/$handle" ]; then - # dont do this with big files - mapfile -t handle_keys < "$temp_dir/$handle" - for key in "${!handle_keys[@]}" - do - printf "%s" "${handle_keys[key]}" > "$temp_dir/$handle.$key" - public_key+=("$temp_dir/$handle.$key") - done + key_index=0 + while IFS= read -r key; do + printf "%s" "${key}" > "$temp_dir/$handle.$key_index" + public_key+=("$temp_dir/$handle.$key_index") + key_index=$((key_index+1)) + done < "$temp_dir/$handle" fi done