provide an alternative to mapfile for older bash (#3717)

This commit is contained in:
Scot Breitenfeld 2023-10-19 10:58:20 -05:00 committed by GitHub
parent c4a146efc4
commit 8c69566da6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -243,9 +243,15 @@ if test -z "$subfile_dir"; then
exit $FAILED
fi
# For bash 4.4+
subfs=$(sed -e '1,/subfile_dir=/d' "$file_config")
mapfile -t subfiles <<< "$subfs"
if command -v mapfile > /dev/null; then
# For bash 4.4+
mapfile -t subfiles <<< "$subfs"
else
while IFS= read -r line; do
subfiles+=("$line")
done <<< "$subfs"
fi
if [ ${#subfiles[@]} -eq 0 ]; then
echo -e "$RED failed to find subfiles list in $file_config $NC"
exit $FAILED